PDA

View Full Version : Solved: find the FIRST used row and column



crmpicco
12-22-2005, 02:36 AM
Last_Col = Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column
Last_Row = Cells.Find("*", SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious).Row


i am using this code to find the LAST USED row/column,
is there code to find the FIRST USED row/column?

thanks.

Picco
http://vbaexpress.com/forum/images/smilies/107.gif

Bob Phillips
12-22-2005, 03:20 AM
set rng = activesheet.usedrange
firstrow = rng.row
firstcol = rng.column

crmpicco
12-22-2005, 03:30 AM
'... The First Column and First Row used in the sheet
Set Rng = ActiveSheet.UsedRange
First_Row = Rng.Row
First_Col = Rng.Column
Set Rng = Nothing


thanks xld

crmpicco
12-23-2005, 02:49 AM
'... The First Column and First Row used in the sheet
Set Rng = ActiveSheet.UsedRange
First_Row = Rng.Row
First_Col = Rng.Column
Set Rng = Nothing


Is this the quickest way to do this?

i.E i notice i am setting an object

Bob Phillips
12-23-2005, 06:01 AM
'... The First Column and First Row used in the sheet
Set Rng = ActiveSheet.UsedRange
First_Row = Rng.Row
First_Col = Rng.Column
Set Rng = Nothing


Is this the quickest way to do this?

i.E i notice i am setting an object

Whichever way you use, you will not be able to discern a difference, we are talking milli-seconds here.