Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I've a workbook with different detail worksheets and one for aggregating. In the aggregate sheet I want to compute a total of some variable which exists on every detail sheet, but not in the same address (row, col). I've taken the following approach: I've devloped a Function Total() in VBA. This function curses through all detail sheets, Find() the Label of the variable and get the value with Offset. As follows: Function Total() As Double Dim tot As Double tot = 0 Dim rng As Range For Each sh In ThisWorkbook.Sheets sh.Select Set rng = sh.Cells.Find("Label") tot = tot + rng.Offset(0, 1).Value Next Total = tot End Function Now the following Sub gives the correct answer: Sub h1() tot = Total Worksheets("aggregate").Range("A1").Value = tot End Sub However, when I enter in sheet Aggregate in cell A1 the formula "=Total()" and compute the workbook, the Label in function Total isn't found and rng is Nothing! What can be at hand? Thanks for help, Henk |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find value in more than 100 worksheets at once | Excel Worksheet Functions | |||
Find across multiple worksheets | Excel Worksheet Functions | |||
Find sum across all worksheets | Excel Worksheet Functions | |||
Find Discrepancies between Worksheets | Excel Discussion (Misc queries) | |||
How can you find how many worksheets in a workbook? | Excel Discussion (Misc queries) |