-1

I have a vb script which copy n number of columns from one workbook to another as of now I am using below code to copy which is copying upto only certain columns (In this case H).

Columns("A:H").Copy

How do I copy the till the last data filled column?

Community
  • 1
  • 1
Santz
  • 95
  • 1
  • 1
  • 6
  • have you tried recording a macro of the action of using CTRL-RIGHT ARROW on the worksheet? This will give you some code to work with. – Our Man in Bananas Jul 10 '14 at 10:05
  • Welcome to Stack Overflow. Please read [Stack Overflow: How to ask](http://stackoverflow.com/questions/how-to-ask) and [Jon Skeet's Question Checklist](http://msmvps.com/blogs/jon_skeet/archive/2012/11/24/stack-overflow-question-checklist.aspx) to find out how to ask a good question that will generate good useful, answers. – Our Man in Bananas Jul 10 '14 at 10:05

2 Answers2

0

You could just use the UsedRange property of the Worksheet objet if you want to be sure not to miss out on any data

Worksheets("YOUR_WS").UsedRange.copy
IAmDranged
  • 2,890
  • 1
  • 12
  • 6
0

You could use the column numbers for this task;

LastColNr = .Cells(1, .Columns.Count).End(xlToLeft).Column
Range(Columns(1), Columns(LastColNr)).Copy
Kokkie
  • 546
  • 6
  • 15