Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default copy different columns from sheet to other sheet

Hello,

Is there an other solution to copy different columns from 1 sheet ("test")
to 2 sheet ("copy_sheet"). I thought to search just columns which have some
data and than copy them to the other sheet ("copy_sheet").

I have some worksheets (30) and I need to go through them and copy it to the
"copy_sheet" just columns which have some data some of them are empty.

I have done some work witch the code below and it works fine but it is not
flexibel if I change something in the sheet so I have to chang the numbers
also in the makro.

Sub CopyFromOtherSheet()
Sheets("test").Activate

Range("A3:M5").Copy Worksheets("copy_sheet").Range("A3")
Range("A9:M9").Copy Worksheets("copy_sheet").Range("A6")
Range("A12:M12").Copy Worksheets("copy_sheet").Range("A7")
Range("A25:M25").Copy Worksheets("copy_sheet").Range("A8")
Range("A28:M28").Copy Worksheets("copy_sheet").Range("A9")
Range("A33:M33").Copy Worksheets("copy_sheet").Range("A10")
Range("A38:M38").Copy Worksheets("copy_sheet").Range("A11")
Range("A43:M43").Copy Worksheets("copy_sheet").Range("A12")
Range("A48:M48").Copy Worksheets("copy_sheet").Range("A13")
Range("A53:M53").Copy Worksheets("copy_sheet").Range("A14")
Range("A58:M58").Copy Worksheets("copy_sheet").Range("A15")
Range("A63:M63").Copy Worksheets("copy_sheet").Range("A16")

End Sub

Thanks in advance!!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default copy different columns from sheet to other sheet

You could give each of those ranges a nice name (insert|Name|define).

Then if you insert/delete columns or rows, the names will still point at the
ranges (as long as you don't destroy that named range).

So

Sub CopyFromOtherSheet()
with Sheets("test")
.Range("copy_001").Copy _
destination:=Worksheets("copy_sheet").Range("paste _001")
....






"p. panter" wrote:

Hello,

Is there an other solution to copy different columns from 1 sheet ("test")
to 2 sheet ("copy_sheet"). I thought to search just columns which have some
data and than copy them to the other sheet ("copy_sheet").

I have some worksheets (30) and I need to go through them and copy it to the
"copy_sheet" just columns which have some data some of them are empty.

I have done some work witch the code below and it works fine but it is not
flexibel if I change something in the sheet so I have to chang the numbers
also in the makro.

Sub CopyFromOtherSheet()
Sheets("test").Activate

Range("A3:M5").Copy Worksheets("copy_sheet").Range("A3")
Range("A9:M9").Copy Worksheets("copy_sheet").Range("A6")
Range("A12:M12").Copy Worksheets("copy_sheet").Range("A7")
Range("A25:M25").Copy Worksheets("copy_sheet").Range("A8")
Range("A28:M28").Copy Worksheets("copy_sheet").Range("A9")
Range("A33:M33").Copy Worksheets("copy_sheet").Range("A10")
Range("A38:M38").Copy Worksheets("copy_sheet").Range("A11")
Range("A43:M43").Copy Worksheets("copy_sheet").Range("A12")
Range("A48:M48").Copy Worksheets("copy_sheet").Range("A13")
Range("A53:M53").Copy Worksheets("copy_sheet").Range("A14")
Range("A58:M58").Copy Worksheets("copy_sheet").Range("A15")
Range("A63:M63").Copy Worksheets("copy_sheet").Range("A16")

End Sub

Thanks in advance!!


--

Dave Peterson
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
How do I copy columns when part of formula has another sheet in it andrewwatkins Excel Discussion (Misc queries) 1 November 4th 07 11:59 PM
How do i copy rows to columns on separate sheet, and have them upd Gre Excel Worksheet Functions 2 November 23rd 06 05:36 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 to sheet Es Excel Discussion (Misc queries) 1 March 7th 05 02:03 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM


All times are GMT +1. The time now is 05:14 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"