A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

macro to copy columns from one sheet to another sheet



 
 
Thread Tools Display Modes
  #1  
Old October 13th 11, 03:13 PM posted to microsoft.public.excel.programming
beginner
external usenet poster
 
Posts: 2
Default macro to copy columns from one sheet to another sheet

I have over 120 columns on one sheet and I would like to copy and
paste every 3rd column onto another sheet. I started to "record"
macro, but was wondering if there was a way to write code for this?

so I have something like this:


x y z x y z ...
1
1
2
3
8
7,etc..


I would like to copy all of the "x" column values onto another sheet.
Any solutions?


Thanks!

Ads
  #2  
Old October 13th 11, 04:56 PM posted to microsoft.public.excel.programming
Don Guillett[_2_]
external usenet poster
 
Posts: 1,517
Default macro to copy columns from one sheet to another sheet

One way change destination sheet and fire from active sheet
Sub copycolumns1()
With Sheets("sheet20")
For i = 1 To Cells(1, Columns.Count) _
..End(xlToLeft).Column Step 3
Columns(i).Copy .Cells(1, .Cells(1, Columns.Count) _
..End(xlToLeft).Column + 1)
Next i
End With
End Sub


On Oct 13, 9:13*am, beginner > wrote:
> I have over 120 columns on one sheet and I would like to copy and
> paste every 3rd column onto another sheet. *I started to "record"
> macro, but was wondering if there was a way to write code for this?
>
> so I have something like this:
>
> x * * * * * *y * * * * *z * * * * * x * * * * *y * * * * *z ...
> 1
> 1
> 2
> 3
> 8
> 7,etc..
>
> I would like to copy all of the "x" column values onto another sheet.
> Any solutions?
>
> Thanks!


  #3  
Old October 13th 11, 06:10 PM posted to microsoft.public.excel.programming
beginner
external usenet poster
 
Posts: 2
Default macro to copy columns from one sheet to another sheet

On Oct 13, 11:56*am, Don Guillett > wrote:
> One way change destination sheet and fire from active sheet
> Sub copycolumns1()
> With Sheets("sheet20")
> For i = 1 To Cells(1, Columns.Count) _
> .End(xlToLeft).Column Step 3
> Columns(i).Copy .Cells(1, .Cells(1, Columns.Count) _
> .End(xlToLeft).Column + 1)
> Next i
> End With
> End Sub
>
> On Oct 13, 9:13*am, beginner > wrote:
>
>
>
> > I have over 120 columns on one sheet and I would like to copy and
> > paste every 3rd column onto another sheet. *I started to "record"
> > macro, but was wondering if there was a way to write code for this?

>
> > so I have something like this:

>
> > x * * * * * *y * * * * *z * * * * * x * * * * *y * * * * *z ...
> > 1
> > 1
> > 2
> > 3
> > 8
> > 7,etc..

>
> > I would like to copy all of the "x" column values onto another sheet.
> > Any solutions?

>
> > Thanks!- Hide quoted text -

>
> - Show quoted text -


I tried it (as is) but it did not work. Is there something I will
need to modify to fit my application specifically?

For example, I got an error with the below:

With Sheets("sheet20") ||I changed the name from "sheet20" to the
current sheet I am working in...this is probably wrong.

Also got an error he
Columns(i).Copy .Cells(1, .Cells(1, Columns.Count) _ ||the macro
also stopped when I got here as .Cells was not specified

Basically I would like to copy the columns (every 3rd column) from
sheet 1 and put them in sheet 2 automatically.
  #4  
Old October 14th 11, 01:24 AM posted to microsoft.public.excel.programming
Cimjet[_3_]
external usenet poster
 
Posts: 157
Default macro to copy columns from one sheet to another sheet

Hi
Yes ,you need to change the sheet name to yours
>>With Sheets("sheet20")<<This is the destination sheet.

You must execute the macro from your dataSheet and the top row must be filled
with data.
HTH
Cimjet

"beginner" > wrote in message
...
On Oct 13, 11:56 am, Don Guillett > wrote:
> One way change destination sheet and fire from active sheet
> Sub copycolumns1()
> With Sheets("sheet20")
> For i = 1 To Cells(1, Columns.Count) _
> .End(xlToLeft).Column Step 3
> Columns(i).Copy .Cells(1, .Cells(1, Columns.Count) _
> .End(xlToLeft).Column + 1)
> Next i
> End With
> End Sub
>
> On Oct 13, 9:13 am, beginner > wrote:
>
>
>
> > I have over 120 columns on one sheet and I would like to copy and
> > paste every 3rd column onto another sheet. I started to "record"
> > macro, but was wondering if there was a way to write code for this?

>
> > so I have something like this:

>
> > x y z x y z ...
> > 1
> > 1
> > 2
> > 3
> > 8
> > 7,etc..

>
> > I would like to copy all of the "x" column values onto another sheet.
> > Any solutions?

>
> > Thanks!- Hide quoted text -

>
> - Show quoted text -


I tried it (as is) but it did not work. Is there something I will
need to modify to fit my application specifically?

For example, I got an error with the below:

With Sheets("sheet20") ||I changed the name from "sheet20" to the
current sheet I am working in...this is probably wrong.

Also got an error he
Columns(i).Copy .Cells(1, .Cells(1, Columns.Count) _ ||the macro
also stopped when I got here as .Cells was not specified

Basically I would like to copy the columns (every 3rd column) from
sheet 1 and put them in sheet 2 automatically.

  #5  
Old October 14th 11, 10:26 AM posted to microsoft.public.excel.programming
Javed
external usenet poster
 
Posts: 91
Default macro to copy columns from one sheet to another sheet

Just a bit alteration in the nice code.Pls try.

Sub CopyColumns1()

Dim col As Long

col = Cells(1, Columns.Count).End(xlToLeft).Column
With Sheets("sheet20")
For i = 1 To col Step 3
Columns(i).Copy .Cells(1, .Cells(1, .Columns.Count) _
.End(xlToLeft).Column + 1)
Next i
End With
End Sub
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to code Macro to Copy fron one sheet and paste in other sheet kay Excel Programming 3 July 25th 08 06:46 PM
Q: Creating a macro to sort and group columns in a sheet according to another sheet [email protected] Excel Programming 0 January 8th 07 10:06 PM
Copy certain columns to another sheet using a macro Shane Nation Excel Programming 2 September 24th 05 05:36 PM
Macro to copy columns from 1st sheet to 2nd according to mapping-p Pawan Excel Programming 2 June 22nd 05 05:53 AM
macro to copy columns to sheet Es Excel Discussion (Misc queries) 1 March 7th 05 03:03 PM


All times are GMT +1. The time now is 02:31 PM.


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