0
votes

I am trying to write VBA code which works on my Excel sheet.

Range("A65536").End(xlUp).Row gives me the row number of the last non blank cell. similarly i am trying to get the row number of the first non blank cell in that particular column. Thanks in advance. madhu

2

2 Answers

3
votes

You can use the same function, just check to see if the first row is blank.

Dim firstRow as Integer

If ActiveSheet.Range("A1").value = "" Then
    firstRow = ActiveSheet.Range("A1").End(xlDown).Row
Else
    firstRow = 1
End If

If the first row is not blank and you use the End(xlDown) call you won't get the first non-empty cell you will get the last non-empty cell before the first blank cell.

0
votes

You can also use the IsEmpty(cell) function, which returns a boolean true/false.