Copy entire columns starting from a certain cell down

C

cheeser83

I need a code that will copy an entire column, such as column A, but
not starting in cell A1. I would like to copy all cells beginning in
A7 down to the last cell used in column A and then I will paste to a
different sheet. I will be doing this with several different columns,
not just column A, but all columns will start and end in the same rows,
but the number of rows used will vary from month to month. I may have
10 rows one month, but 1000 the next.

Any help is much appreciated!
 
T

Tom Ogilvy

This copies columns A, G, I , V


Dim v as Variant, col as Long
v = Array(0,6,8,21) ' A, G, I, V
col = 1
set rng = Range(Cells(7,1),Cells(rows.count,1).End(xlup))
for i = lbound(v) to ubound(v)
rng.offset(,v(i)).copy Destination:= _
worksheets("sheet2").Cells(1,col)
col = col + 1
Next
 
C

cheeser83

Thank you for the code. I am trying to decipher it as best I can. I
have a medium understanding of VBA. What part of the code is telling
it where to paste? I would like to be able to change it to paste in a
different area. For example, what it copies our of column A on sheet
1, I want to paste it to column B starting in row 7.

Thank you very much for your help.
 
T

Tom Ogilvy

Dim v as Variant, col as Long
v = Array(0,6,8,21) ' A, G, I, V
col = 2 '<================= specify first column
set rng = Range(Cells(7,1),Cells(rows.count,1).End(xlup))
for i = lbound(v) to ubound(v)
rng.offset(,v(i)).copy Destination:= _
worksheets("sheet2").Cells(7,col) '<== row 7
col = col + 1
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top