View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default how to consolidate sheets

Sub ConsolidateSheets()
Dim sh As Worksheet, rng As Range
Dim rng1 As Range, cell As Range
Dim cell1 As Range
With Worksheets("Z")
Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
Set rng1 = .Range("C5:F10,H10:P15")
rng1.Value = 0
If rng.Count 25 Then
Set rng = .Range("A1")
End If
If IsEmpty(rng) Then Exit Sub
End With
For Each cell In rng
Set sh = Worksheets(cell.Value)
For Each cell1 In rng1
If IsNumeric(sh.Range(cell1.Address).Value) Then
cell1.Value = cell1.Value + sh.Range(cell1.Address)
End If
Next
Next
End Sub

Worked for me.

--
Regards,
Tom Ogilvy




"tommasopalazzot"
<tommasopalazzot.1y1ovy_1131229801.7552@excelfor um-nospam.com wrote in
message news:tommasopalazzot.1y1ovy_1131229801.7552@excelf orum-nospam.com...

1)yes,there are no data in column A
2)I just want to do the addition in code and place the sum in the
cells
3)data area is in the cells C5:F10,H10:P15
4)only numbers,no text


--
tommasopalazzot
------------------------------------------------------------------------
tommasopalazzot's Profile:

http://www.excelforum.com/member.php...o&userid=27730
View this thread: http://www.excelforum.com/showthread...hreadid=482527