Adding workbook values to a summary workbook.

xzmike

Board Regular
Joined
Feb 15, 2002
Messages
110
I'm looping thru various workbooks and adding values in row 18, columns "H" thru "Q" to a workbook named Master with a sheet named Summary. In the code, when I reach the first cell of H18 in the workbook I'm looping thru, I want that value added to cell H18 of the Master.Summary workbook/sheet. When I loop thru the next workbook (code not shown) I want perform the same action. The end result is that Master.Summary H18 (and other cells) will have the summed values of the individual sheets.

For example, if I'm in cellH18 of the activeworkbook, I would like the code to saysomething like " Master.Summary.Range(H18).value=Master.Summary.Range(H18).value + Activeworkbook.Activesheet.Range(H18).value.

Thanks for any help
Mike


Dim rngTarget As Range
Dim wks As Worksheet

Set wks = ActiveSheet

For Each wks In ActiveWorkbook.Worksheets
Set rngTarget = wks.Range("H" &18 ":Q" & 18)
For Each rng In rngTarget
I'M NOT SURE WHAT CODE GOES IN HERE.
Next rng
Next

End Sub
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

sweater_vests_rock

Well-known Member
Joined
Oct 8, 2004
Messages
1,657
xzmike.

replace "NOT SURE WHAT TO PUT HERE"

with something like this:

Code:
rngTarget.Cells(1, i).Copy
Master.Summary.Cells(rngTarget.Cells(1,i).Address).PasteSpecial xlPasteValuesAndNumberFormats, xlPasteSpecialOperationAdd
you might have to .Select your Master before pasting...i never can remember if that is a problem or not.

hope this helps. ben.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,168
Messages
5,570,645
Members
412,335
Latest member
cinciri99
Top