Sumif Precedents VBA

vikeshjain1981

New Member
Joined
Sep 25, 2014
Messages
1
Hi everybody

I have a huge workbook (17MB) with 19 sheets. In the summary sheet we have Sumif and Sumifs formulas. Now to review the sheet I need to trace the actual values referred to by those formulas (not the range). I have tried several excel auditing addins (Aaron T. Blood's Explode, JKP Reftreeanalyzer, Dependency auditor, Arixcel explorer etc) - they all refer to general ranges but not the specific values. In the end I found Héctor Miguel code which does what I am looking for - but it has following shortcomings:

1. Works only on Sumif and not Sumifs (back then they didnt had sumifs?)
2. Works only if the range is on the same sheet
3. Works only if the criteria is picked from another cell - if it is hardcoded within the formula (e.g. "A" instead of F4) then it is not working

Can somebody please help me..

Héctor Miguel Code
Sub myMatchingSumif()
Dim theFunction As String, theCriteria As String, theCondition As String, _
theResults As String, theRange As Range, n As Integer, Temp As String, Tmp
If ActiveCell.HasFormula Then theFunction = ActiveCell.Formula Else Exit Sub
If Mid(theFunction, 2, 5) <> "SUMIF" Then Exit Sub
Temp = Mid(theFunction, 8, Len(theFunction) - 8)
Tmp = Split(Temp, ",")
theCriteria = Tmp(LBound(Tmp))
theCondition = Tmp(LBound(Tmp) + 1)
theResults = Tmp(LBound(Tmp) + 2)
With Range(theCriteria)
For n = 1 To .Count
If .Cells(n) = Range(theCondition) Then
Set theRange = Union(IIf(theRange Is Nothing, _
Range(theResults).Cells(n), theRange), Range(theResults).Cells(n))
End If
Next
End With
If Not theRange Is Nothing Then theRange.Select: Set theRange = Nothing
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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