View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Cell referencing in Macros

Hi,

Find the last row in column A with this

lastrow = Sheets("Sheet1").Cells(Cells.Rows.Count, "A").End(xlUp).Row


and either of these to paste into the cell below that.

Range("A" & lastrow + 1).PasteSpecial
Cells(lastrow + 1, 1).PasteSpecial
Cells(lastrow + 1, "A").PasteSpecial


Mike
"Bern Notice" wrote:

When writing macros that will highlight and move data around, how do you
highlight the data when it will have different numbers of rows each time you
run the macro. Is there a way to simulate the typing <end<down arrow to go
to the bottom of the range (no matter how big or small it is)?

Also, how do change the reference cell each time you run the macro. For
example, you want to continue to add data to the end of the list which keeps
growing each time you run the macro. I am having problems because my macro
wants to insert the copied data in the same cell reference each time instead
of going to the bottom of the list.

Does this have to be done in visual basic or can you create the macro with
the recorder?