Last Cell In Row

K

kirkm

Found this vis Goggle

Sub LastCellInRow()

Range("IV1").End(xlToLeft).Select

End Sub


It says it gives you the last Cell in a row.

But I can't see where you tell it the row or how you see the result.

I know my highest col is "CP" or 94 and was going to use this -

for x = 94 to 1 step -1
if Cells(10,x)> "" then Answer = x:Exit For
next x

Once the fisrt method is working, which is best ?

Thanks - Kirk
 
R

RyanH

This is the fastest way to find the last column with a value in it for Row 1.
Just change the row number to find the last column with a value in it.

ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
 
S

ShaneDevenshire

Hi,

what's the question?

All this code does is find the last cell on row 1 that contains data
provided that IV1 does not contain data.
 
K

kirkm

This is the fastest way to find the last column with a value in it for Row 1.
Just change the row number to find the last column with a value in it.

ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column

Thank you !

Cheers - Kirk
 
K

kirkm

Hi,

what's the question?

All this code does is find the last cell on row 1 that contains data
provided that IV1 does not contain data.

Gidday, Really? Glad it works for some then !
How did you get a return value and what is IV1 ? I was lost after
realising that wasn't a line number - to reference the column from !

Cheers - Kirk
 
R

RyanH

IV1, IV is the Column Label and 1 is the Row Label.

If my posts helped. Please click "YES" below.
 
K

kirkm

IV1, IV is the Column Label and 1 is the Row Label.

I should give up ! The requirement was to find the column - that
example seems to want it first, but if you knew what it was you
wouldnt need to know again !!!!

Cheers - Kirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top