Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pasting after last record
Hi all
I am cutting and pasting between worksheets using a macro and need to add records to the end of a list, i.e. have already pasted 2000 rows, and want to paste starting from row 2001, but am not able to specify the row number as it varies every time. Is there a vba command that will automatically paste after last row? Thanks in advance Andy |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pasting after last record
Try this (or variations of it)
Range("a1").CurrentRegion.End(xlDown).Offset(1, 0).Select Starting form somewhere in the existing data (above, "a1") Current Region.end(xlDown) will take you to the last entry (the end being determined by blank cells) Offset(1,0) goes down one row further than that. This illustration then Selects that cell, you can do other things, such as Paste. "Andy Wilkinson" wrote: Hi all I am cutting and pasting between worksheets using a macro and need to add records to the end of a list, i.e. have already pasted 2000 rows, and want to paste starting from row 2001, but am not able to specify the row number as it varies every time. Is there a vba command that will automatically paste after last row? Thanks in advance Andy |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pasting after last record
Some mo
Assuming that none of the records can have the cell in column [A] empty (change the column letter as appropriate): Sheets(1).Cells(65356,"A").End(xlUp).Row+1 Regards, KL "Adrian" wrote in message ... Try this (or variations of it) Range("a1").CurrentRegion.End(xlDown).Offset(1, 0).Select Starting form somewhere in the existing data (above, "a1") Current Region.end(xlDown) will take you to the last entry (the end being determined by blank cells) Offset(1,0) goes down one row further than that. This illustration then Selects that cell, you can do other things, such as Paste. "Andy Wilkinson" wrote: Hi all I am cutting and pasting between worksheets using a macro and need to add records to the end of a list, i.e. have already pasted 2000 rows, and want to paste starting from row 2001, but am not able to specify the row number as it varies every time. Is there a vba command that will automatically paste after last row? Thanks in advance Andy |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pasting after last record
There are many different way to get the last row, the two I like a
Dim lRow as long lRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row lRow = Range("A" & Rows.Count).End(xlUp).Row Note that there's no 'hardcoding' of the know last row (65356). This way if a newer version of Excel allows more rows there no need to change the code to find the last row. "KL" wrote: Some mo Assuming that none of the records can have the cell in column [A] empty (change the column letter as appropriate): Sheets(1).Cells(65356,"A").End(xlUp).Row+1 Regards, KL "Adrian" wrote in message ... Try this (or variations of it) Range("a1").CurrentRegion.End(xlDown).Offset(1, 0).Select Starting form somewhere in the existing data (above, "a1") Current Region.end(xlDown) will take you to the last entry (the end being determined by blank cells) Offset(1,0) goes down one row further than that. This illustration then Selects that cell, you can do other things, such as Paste. "Andy Wilkinson" wrote: Hi all I am cutting and pasting between worksheets using a macro and need to add records to the end of a list, i.e. have already pasted 2000 rows, and want to paste starting from row 2001, but am not able to specify the row number as it varies every time. Is there a vba command that will automatically paste after last row? Thanks in advance Andy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I need to have a record number change for every record | Excel Discussion (Misc queries) | |||
Open new record with selected fields from previous record | Excel Discussion (Misc queries) | |||
Finding last record in month for each of several types of record. | Excel Programming | |||
Record Macro - Record custom user actions | Excel Programming | |||
Need help autopopulating next new record with previous record data | Excel Programming |