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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add a new row after last existing row

Status
Not open for further replies.

stewglyn

Programmer
Apr 4, 2002
9
0
0
GB
I need to add a row into an excel spreadsheet after the last row with text in it. Either through a macro or vba. Just can't seem to get there. Any ideas recieved gratefully!
 
Hi,

First, here's a function that returns the last row number.
Code:
Function LastRow() As Long
    With ActiveSheet.UsedRange
        LastRow = .Rows.Count + .Row - 1
    End With
End Function
Then use the function to select the last row...
Code:
   Cells(LastRow, 1).Select
Hope this helps :)
Skip,
Skip@TheOfficeExperts.com
 
thank you that works but when i try and then copy the contents of the last row which your function leads me to I can't get it to work dynamically and keep copying and pasting the last row to the next one down. Thanks for your help though.

stewart
never looked at excel vba til now I'll stick to access!
 
Well i have a booking system. Each new booking is added onto the end of the existing range as a new row. Each of the existing rows has various formats on the cells. On click of a button i want to make the first cell on the row below the last row in the range active. I thought i could find the end of the range, copy the last row in the range into the row below and then use the clear contents method.

stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top