Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.office.developer.vba,microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Copy entire columns starting from a certain cell down

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 6,953
Default Copy entire columns starting from a certain cell down

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


--
Regards,
Tom Ogilvy



"cheeser83" wrote:

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!


  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 13
Default Copy entire columns starting from a certain cell down

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.


Tom Ogilvy wrote:
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


--
Regards,
Tom Ogilvy



"cheeser83" wrote:

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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy entire row, not just cell in row JOUIOUI Excel Programming 1 June 21st 06 03:42 AM
How to indicate in formula to choose the entire column starting from a specified cell? [email protected] Excel Discussion (Misc queries) 3 June 13th 06 04:25 AM
Getting macro to copy to starting cell sony654 Excel Worksheet Functions 3 February 4th 06 07:16 PM
Copy one cell to entire column Tom Excel Discussion (Misc queries) 3 April 28th 05 03:26 PM
Copy one cell to entire column Tom Excel Discussion (Misc queries) 6 April 27th 05 11:39 PM


All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"