ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I make a macro seek the botom of a list? (https://www.excelbanter.com/excel-programming/443022-how-do-i-make-macro-seek-botom-list.html)

chads_vstream[_2_]

How do I make a macro seek the botom of a list?
 
I'm trying to copy data from a file and paste it at the bottom of other data
using a macro. manually, i would copy the selection toggle to my other open
sheet, press CTRL <down to jump to the bottom of the data and then paste.
when i try this in a macro it always jumps to a specific cell rather than a
relitive one. anyone know how to rewrite the VB code to make this relitive?

Mike H

How do I make a macro seek the botom of a list?
 
Hi,

In a macro this would find the last used cell in colum A of the active sheet

LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row

So we add 1 to that to get the empty cell below

LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row+1

And to turn that into a range to paste into we could use

Range("A" & Lastrow).pastespecial

or whatever type of paste you want to do
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"chads_vstream" wrote:

I'm trying to copy data from a file and paste it at the bottom of other data
using a macro. manually, i would copy the selection toggle to my other open
sheet, press CTRL <down to jump to the bottom of the data and then paste.
when i try this in a macro it always jumps to a specific cell rather than a
relitive one. anyone know how to rewrite the VB code to make this relitive?



All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com