Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code that selects a bunch of sheets, and then
copies a row and pastes the formula in that row to a set range. This code takes a while to run. Generally speaking, would a for next loop be faster? Or is there an even faster way (ie a do while loop?) Thanks! Set shtarray = Sheets Array "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Steph,
I can't see how this is copying from more than just Sheet1. Generally speaking, a loop is a loop, Do While, Do Until, For Next, it is unlikely that any will be faster than another to any significance. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message om... I have the following code that selects a bunch of sheets, and then copies a row and pastes the formula in that row to a set range. This code takes a while to run. Generally speaking, would a for next loop be faster? Or is there an even faster way (ie a do while loop?) Thanks! Set shtarray = Sheets Array "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob. Thaks for the response. As for my crappy code, it started with the
macro recorder. So code aside, I selected several sheets using the ctl key, then copied a row with formulas in it (each sheet has a row of formulas in the same row), then copied it to a range. It works....just slowly. So that being said, do you think a loop will be faster than my crappy-code method? I'm no great coder, so I'm just looking for a bit of reassurance before I try to tackle the writing of the loop!! Thanks again! "Bob Phillips" wrote in message ... Steph, I can't see how this is copying from more than just Sheet1. Generally speaking, a loop is a loop, Do While, Do Until, For Next, it is unlikely that any will be faster than another to any significance. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message om... I have the following code that selects a bunch of sheets, and then copies a row and pastes the formula in that row to a set range. This code takes a while to run. Generally speaking, would a for next loop be faster? Or is there an even faster way (ie a do while loop?) Thanks! Set shtarray = Sheets Array "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Steph,
The point I was making was that I couldn't comment as to whether a loop would be quicker than your code, as I couldn't see how your code worked through all the sheets, it only seemed to do one to me. How does you code process all the sheets? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message ... Hi Bob. Thaks for the response. As for my crappy code, it started with the macro recorder. So code aside, I selected several sheets using the ctl key, then copied a row with formulas in it (each sheet has a row of formulas in the same row), then copied it to a range. It works....just slowly. So that being said, do you think a loop will be faster than my crappy-code method? I'm no great coder, so I'm just looking for a bit of reassurance before I try to tackle the writing of the loop!! Thanks again! "Bob Phillips" wrote in message ... Steph, I can't see how this is copying from more than just Sheet1. Generally speaking, a loop is a loop, Do While, Do Until, For Next, it is unlikely that any will be faster than another to any significance. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message om... I have the following code that selects a bunch of sheets, and then copies a row and pastes the formula in that row to a set range. This code takes a while to run. Generally speaking, would a for next loop be faster? Or is there an even faster way (ie a do while loop?) Thanks! Set shtarray = Sheets Array "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob. That's odd, it works on all sheets in the array for me. Perhaps I
copied the sample code into the moriginal message incorrectly. I pasted it again below. Thanks for your time! Sub Pop_Forecast() Dim shtarray As Sheets Dim frng As Range Dim sh As Worksheet Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Set shtarray = Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula - every sheet has a formula in each cell of this row Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas Application.Calculation = xlCalculationAutomatic "Bob Phillips" wrote in message ... Steph, The point I was making was that I couldn't comment as to whether a loop would be quicker than your code, as I couldn't see how your code worked through all the sheets, it only seemed to do one to me. How does you code process all the sheets? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message ... Hi Bob. Thaks for the response. As for my crappy code, it started with the macro recorder. So code aside, I selected several sheets using the ctl key, then copied a row with formulas in it (each sheet has a row of formulas in the same row), then copied it to a range. It works....just slowly. So that being said, do you think a loop will be faster than my crappy-code method? I'm no great coder, so I'm just looking for a bit of reassurance before I try to tackle the writing of the loop!! Thanks again! "Bob Phillips" wrote in message ... Steph, I can't see how this is copying from more than just Sheet1. Generally speaking, a loop is a loop, Do While, Do Until, For Next, it is unlikely that any will be faster than another to any significance. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message om... I have the following code that selects a bunch of sheets, and then copies a row and pastes the formula in that row to a set range. This code takes a while to run. Generally speaking, would a for next loop be faster? Or is there an even faster way (ie a do while loop?) Thanks! Set shtarray = Sheets Array "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Steph,
I actually tested it now, and see what you are doing. As such, I don't think that a loop will be quicker than the way you are doing it. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message ... Hi Bob. That's odd, it works on all sheets in the array for me. Perhaps I copied the sample code into the moriginal message incorrectly. I pasted it again below. Thanks for your time! Sub Pop_Forecast() Dim shtarray As Sheets Dim frng As Range Dim sh As Worksheet Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Set shtarray = Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula - every sheet has a formula in each cell of this row Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas Application.Calculation = xlCalculationAutomatic "Bob Phillips" wrote in message ... Steph, The point I was making was that I couldn't comment as to whether a loop would be quicker than your code, as I couldn't see how your code worked through all the sheets, it only seemed to do one to me. How does you code process all the sheets? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message ... Hi Bob. Thaks for the response. As for my crappy code, it started with the macro recorder. So code aside, I selected several sheets using the ctl key, then copied a row with formulas in it (each sheet has a row of formulas in the same row), then copied it to a range. It works....just slowly. So that being said, do you think a loop will be faster than my crappy-code method? I'm no great coder, so I'm just looking for a bit of reassurance before I try to tackle the writing of the loop!! Thanks again! "Bob Phillips" wrote in message ... Steph, I can't see how this is copying from more than just Sheet1. Generally speaking, a loop is a loop, Do While, Do Until, For Next, it is unlikely that any will be faster than another to any significance. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Steph" wrote in message om... I have the following code that selects a bunch of sheets, and then copies a row and pastes the formula in that row to a set range. This code takes a while to run. Generally speaking, would a for next loop be faster? Or is there an even faster way (ie a do while loop?) Thanks! Set shtarray = Sheets Array "Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6")) shtarray.Select Sheets("Sheet1").Activate 'Copy Formula Range("A2:EC2").Copy Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row) frng.Select Selection.PasteSpecial Paste:=xlPasteFormulas |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
category label spacing (x-axis generally) | Charts and Charting in Excel | |||
My computer keeps speaking out cells in excel, no other program | Excel Discussion (Misc queries) | |||
can this be done faster? | Excel Discussion (Misc queries) | |||
Should I generally request "post a poll" when I post a new thread? | Excel Discussion (Misc queries) | |||
Can faster CPU+larger/faster RAM significantly speed up recalulati | Excel Discussion (Misc queries) |