Hello,
This can be quite complex and typically requires a combination of formulas or a macro to iterate through each sheet. Since you don’t know the number of sheets or their names in advance, this adds to the complexity. Here’s a general approach using VBA, which you can customize according to your specific setup:
Create a VBA Macro: Write a VBA script that loops through each sheet in the workbook, checks the specific cell for the room number, and if it matches, pulls the data from the designated cells.
Set up a userform or input cell: On your Totals Page, provide a way to enter the room number you want to search for.
Automate the data collection: When a room number is entered, the macro can be triggered to search through all the sheets and aggregate the data in the specified location on the Totals Page.
Here's a simplified example of what the VBA code might look like:
Sub AggregateData()
Dim ws As Worksheet
Dim roomNumberToFind As String
Dim targetCellValue As String
Dim total As Double
Dim targetRange As Range
' Replace with the actual cell where the room number is input on the Totals Page
roomNumberToFind = Sheets("TOTAL PAGE"). Range("B2"). Value
total = 0
For Each ws In ThisWorkbook.Worksheets
If ws. Name <> "TOTAL PAGE" Then ' Replace with your Totals Page sheet name
' Replace 'A1' with the cell that contains the room number in the panel sheets
targetCellValue = ws. Range("A1"). Value
If targetCellValue = roomNumberToFind Then
' Replace 'B2:B10' with the actual range you want to sum up from the panel sheets
Set targetRange = ws. Range("B2:B10")
total = total + Application.WorksheetFunction.Sum(targetRange)
End If
End If
Next ws
' Replace 'C2' with the cell on the Totals Page where you want to display the total
Sheets("TOTAL PAGE"). Range("C2"). Value = total
End Sub
Please note that this is a very basic template. The exact implementation will depend on the structure of your workbook, the specific data you're trying to pull, and how you want it displayed on the Totals Page.
Hope this helps!
Warm Regards,
Ozi