Once you have all the names in your summary sheet (use Ken's code to build it if
you need to), you can use a bunch (a big bunch) of =vlookup()'s.
In general, your =vlookup() will look like this (assuming the names of the
"detail" sheets are Jan-Dec).
=VLOOKUP($A2,'Jan'!$A:$B,2,FALSE)
through
=VLOOKUP($A2,'Dec'!$A:$B,2,FALSE)
(the single quotes aren't required, but will be if your worksheet name is
special--has spaces, consists of only digits....)
But if the value isn't found on a detail sheet (Jan-Dec), then you'll get #n/a's
back.
You can hide them by adjusting your formula:
=IF(ISERROR(VLOOKUP($A2,'3'!$A:$B,2,FALSE)),0,VLOOKUP($A2,'3'!$A:$B,2,FALSE))
=======
But you may want to use Ken's program to create the summary.
If you sheet names are nice abbreviation of months, you can use that and build a
nice pivottable that does the work for you.
I modified Ken's code slightly to actually put a date in column A of the
intermediate summary worksheet. This makes the pivottable easier to sort (April
comes before January in an alphabetic sort).
Option Explicit
Sub SummaryData()
Dim wks As Worksheet
Dim sd As Worksheet
Dim sht As Long
Dim lrow1 As Long
Dim lrow2 As Long
Dim StRow As Long
Dim testStr As String
StRow = 2
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Summary Sheet").Delete
Application.DisplayAlerts = False
On Error GoTo 0
Set wks = Worksheets.Add
With wks
.Move Before:=Sheets(1)
.Name = "Summary Sheet"
.Range("A1:C1").Value = Array("Sheet", "Name", "Revenue")
End With
For sht = 2 To ActiveWorkbook.Sheets.Count
Set sd = Sheets(sht)
lrow1 = wks.Cells(Rows.Count, "B").End(xlUp).Row
lrow2 = sd.Cells(Rows.Count, "B").End(xlUp).Row
sd.Activate
sd.Range(Cells(StRow, 1), Cells(lrow2, 2)).Copy wks.Cells(lrow1 + 1, 2)
testStr = sd.Name & " 1, 2004"
If IsDate(CDate(testStr)) Then
testStr = CDate(testStr)
Else
testStr = "'" & sd.Name
End If
wks.Cells(lrow1 + 1, 1).Resize(lrow2 - (StRow - 1), 1).Value = testStr
Next sht
wks.Columns(1).NumberFormat = "mmm"
wks.Activate
End Sub
========
After you do this, try building the pivottable manually.
Select your range A1:C9999 (or as far as you need).
Data|Pivottable
Follow the wizard until you get to a step with a Layout button
click that button
Drag the Sheet button to the column field
drag the Name button to the row field
drag the revenue button to the data field
(if it doesn't say Sum of revenue, double click on it and change it to sum.)
The finish it up.
If you like this idea, record a macro when you do it manually and add it to
Ken's code.
If you need help tweaking the code, post back with your problem (in plain
text--no workbooks) and I'm sure you'll get help.