Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro- go to next empty row when data is variable?

Status
Not open for further replies.

gritz

Programmer
Apr 24, 2003
14
US
I am trying to record a macro in Excel. I am poplulating a worksheet with a variable number of rows from an external source, and I want to go to the next empty row to perform the next action. Is there a function in Excel that will get me there?
 
Assuming you never have a blank cell in column "A" you could use something like this:
[blue]
Code:
Sub NextAvailableRow()
  Range("A1").End(xlDown).Offset(1, 0).Select
End Sub
[/color]

Alternatively, if you might have a blank cell in the column, then you could use something like this:
[blue]
Code:
Sub NextAvailableRow()
  With ActiveSheet.UsedRange
    Range("A" & (.Rows.Count - .Cells(1, 1).Row + 2)).Select
  End With
End Sub
[/color]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top