find the first used row

Excelboo2

Board Regular
Joined
Oct 11, 2006
Messages
175
I have written the following script to find the last row which contain data:

lastrow=cells(65,000,1).End(xlup).row

how should I write it if I want to find the first row which contain data

Thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Jon von der Heyden's suggestion will set FirstRow as the first used row.
This may not necessarily be the same as the first row with data.

To find the first row with data :-

Code:
On Error Resume Next
FirstRow = Cells.Find(What:="*", After:=[IV65536], _
    SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
On Error GoTo


An alternative to Jon von der Heyden's suggestion :-

FirstRow = ActiveSheet.UsedRange.Cells(1).Row

Except that if the whole sheet is blank, this will return 1 whereas Jon von der Heyden's suggestion will return 0
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,362
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top