Code macro how to select used rows of a column

[Closed]
Report
-
Posts
2805
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 14, 2021
-
Hello everybody,

I'm struggle with my macro code. I would like to copy data to a worksheet and paste them to another.
My problem is everyday the data could be different.

Below this is the code I'm using. I found a way bu that means I copy 20000 rows whereas I could have only 20 rows to copy.

Windows("fitment.xls").Activate
Range("A1:I20000").Select
Range("I20000").Activate
Selection.Copy
Windows("portbury_extract_technical.xlsm").Activate
Sheets("fitment executed").Select
Range("A3").Select
ActiveSheet.Paste
Application.CutCopyMode = False


Thank you for your help...

1 reply

Posts
2805
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 14, 2021
481
Hi Kevin,

Instead of using:
Range("I20000").Activate
Try this:
Range("I2:I"&cells(rows.count,"I").end(xlup).row).activate

Best regards,
Trowa