PDA

View Full Version : Can anyone suggest a faster way to accomplish this



austenr
11-07-2006, 10:15 AM
In the attached workbook, there are four sheets;
Master, September, August and July. I need to take the subtotals in each month and paste them in the corresponding place on the master sheet.

What is in B & C needs to go on the master sheet under the corresponding month. Tried a couple of lookup functions but the entries that had no assigned value were filled with the last value in memory. Any help is appreciated. Thanks

mdmackillop
11-07-2006, 01:05 PM
Hi Austen
Copy and paste these formule. You can then copy and paste them form G&H to the corresponding cells in each month. I see that July has data in a different column, so chane the Sumif accordingly. Note that cell F1 etc MUST be the same as the sheet name.
If you don't want thousands of Sumifs, use the following code to write the values from row 3 down. Row 2 should preserve the formulae.
Regards
MD

G2 formula =SUMIF(INDIRECT(F$1&"!A:A"),Master!F2,INDIRECT(F$1&"!B:B"))
H2 Formula =SUMIF(INDIRECT(F$1&"!A:A"),Master!F2,INDIRECT(F$1&"!C:C"))

Option Explicit
Sub CopyFormulae()
Dim LRw As Long
Dim Cols, Col
Cols = Array(7, 11, 16)
LRw = Cells(Rows.Count, 1).End(xlUp).Row
For Each Col In Cols
Range(Cells(2, Col), Cells(LRw, Col + 1)).FillDown
Range(Cells(3, Col), Cells(LRw, Col + 1)).Copy
Cells(3, Col).PasteSpecial Paste:=xlPasteValues
Next
End Sub

austenr
11-07-2006, 01:16 PM
Thanks Malocmb. The VBA will do quite nicely. A million thanks as usual.