Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macro to copy multiple selctions to different pages

I am trying to write a macro that will select rows from "sheet 1" and
depending on the value in column "BU" copy the row to sheets 2, 3 or 4
given the following condition.

If the cell in column BU = 1 then copy to sheet 2; I
f the cell in column BU = 2 then copy to sheet 3;
If the cell in column BU = 3 then copy to sheet 4

The copied rows need to be inserted in sheets 2,3 & 4 from row 13 down
to account for the header.

The detrmining number in BU is set using and IF statement in excel, I
assume this shouldn't have any impact on the macro code required?

I have tried a number of differnt approaches but no joy as yet which
is no doubt not helped by my lack of experience with VB.

Any help would be gratefully appreciated as would any comments on the
code suggested to help understand the procedures.

Many Thanks

Jamie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Macro to copy multiple selctions to different pages

You didn't say what row of BU. Try this, supplying the intended rows.

Sheets("Sheet1").Rows("r1:r2").Copy _
Destination:= Sheets("Sheet" & 1 + Sheets("Sheet1").Cells(r3,
"BU")).Rows("13")

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macro to copy multiple selctions to different pages

Thanks for the suggestion. I dont think I was very clear about what I
was trying to do. I need to search the cells in column BU down to the
end of the data and copy the rows to seperate sheets depending on the
value in BU. The thing Im really struggling with is how to implement
3 seprate "If" conditions.

If the value in cell BU?? is 1, I need to copy the entire row to sheet
2. If the value in cell BU?? is 2, I need to copy to sheet 3 and
finally if BU?? = 3 I need to copy the entire row to sheet 4. (I have
put the ?? in to represent different row numbers). My header is 12
rows so the data is from row13 downwards. The headers on sheets 2 , 3
and 4 are tghe same.

Thanks

Jamie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Macro to copy multiple selctions to different pages

My code does exactly what you say. The value of 1 +
Sheets("Sheet1").Cells(r3,
"BU") will vary depending on what is in column BU. If it = 1, Sheet2
will be used. If it = 2, Sheet3 will be used, etc. If you want to
copy from multiple rows, then put my code within a loop.

Hth,
Merjet


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 cells from multiple pages to one sheet w/ if statement GHall Excel Worksheet Functions 8 January 15th 09 08:24 PM
Copy Excel to Word - Multiple Pages Yvonne New Users to Excel 1 February 17th 07 01:01 AM
Adapting Excel 4 Macro Page Setup for multiple pages SkiBumScot Excel Programming 1 January 3rd 07 01:12 PM
Error using a macro to print multiple pages. [email protected] Excel Discussion (Misc queries) 2 June 21st 06 06:47 AM
How do I allow multiple drop down list selctions in one cell Energy New Users to Excel 2 May 10th 06 10:45 AM


All times are GMT +1. The time now is 01:35 AM.

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"