Code macro how to select used rows of a column

Closed
Kevin - 16 Dec 2015 à 11:19
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 21 Dec 2015 à 11:02
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...
Related:

1 response

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
21 Dec 2015 à 11:02
Hi Kevin,

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

Best regards,
Trowa