Alternative to INDIRECT to SUMIF in multiple worksheets

ongcaps

New Member
Joined
Sep 7, 2016
Messages
12
Hi Community,

I am using Excel 2010.

I have a problem with the formula below because it makes the workbook VERY slow:

Code:
=IF(B$2="",0,SUMPRODUCT(SUMIF(INDIRECT("'"&Tabs&"'!B25:B245"),B$2,INDIRECT("'"&Tabs&"'!L25:L245"))))

I am trying to do a SUMIF in 80 worksheets (named range 'Tabs') and the structure of each of the 80 tabs is the same. B$2 in this case is 'Source 1' in the table below. I have a similar formula in each of the cells with '0'.

Source 1Source 2Source 3Source 4Source 5
Refresher training & workshops00000
Personnel00000
Communications00000
Maintenance00000
Supplies, utilities & other recurrent cost00000
Buildings00000
Equipment00000
Vehicles00000
Consultants00000
TOTAL00000

<tbody>
</tbody>


Is there any alternative to INDIRECT in this formula?

Thank you very much in advance.

Cheers,
Daniel
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Have you thought abut using VBA and variant arrays to do the whole calcualtion. It should be very fast and will speed up the Excel recalculation enormously
 
Upvote 0
Thank you offthelip.

I am not familiar with variant arrays. How can you build them?

I was thinking to put all the information from the 80 sheets into a single table and do the calculations from there. Is this what you are proposing?

Cheers,
Daniel
 
Upvote 0
It's definitely a good idea to have all of the data in a single sheet and process the data with the native functions.
 
Upvote 0
This code will loop through all worksheets in the workbook except "Sheet1" which I have excluded to show you how to avoid any you don't want included
It will then sum the values in column L which mathch the text in column A. It will also do it all in a flash!! I have commented the code to led you through what it is doing
Note I don't use option explicit I prefer to use my time typing comments
Code:
Sub tewst()

With Worksheets("Sheet1")
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
' get list to do the mathc on
inarr = Range(Cells(1, 1), Cells(lastrow, 2))
End With
WS_Count = ActiveWorkbook.Worksheets.Count
' loop through all worksheets
For i = 1 To WS_Count
   ' excleude any worksheets here
   If ActiveWorkbook.Worksheets(i).Name <> "Sheet1" Then
     ' load the data to search into a variatn array
       


     sercharr = Worksheets(i).Range("B25:L245")
     
          ' loop through all the varaibles to search for
       For j = 1 To lastrow
        ' loop through the search data
         For k = 1 To 220
          ' look for a match
           If inarr(j, 1) <> "" Then
           If inarr(j, 1) = sercharr(k, 1) Then
            ' add into the sum
            inarr(j, 2) = inarr(j, 2) + sercharr(k, 11)
           End If
           End If
         Next k
      Next j
   End If
 Next i
 ' write the varaint array out to worksheet
With Worksheets("Sheet1")
 
 Range(Cells(1, 1), Cells(lastrow, 2)) = inarr
End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top