Thanks to mirabeau @ Mrexcel for original script.
What the original code does Sums every range in the K column and adds total to end
What I want it to do Replace the sum with a sumif that sums only the cells meeting the criterion cell, unless the criterion cell containts "Bloomingdales*". Then the entire range should be summed.
The issue I am checking if formula cell.offset(-4,-10) equals the exception. I am however having troubles mixing variables and strings and even variables and variables. Ideally, it should check if e = Store or if e = "Bloomingdales*". Either the code won't execute, or I only get it to display "e=store", where Excel can't interpret the VBA variables.
My attempt:
Sub addups()
Dim e As Range, f As Range, g As Range, u As String, x As Range, Store As String
Set e = Columns("K").Rows(2) 'any column and/or start row you like
If e = "" Then Set e = e.End(4)
Do
Set g = e
If e.Offset(1) <> "" Then Set e = e.End(4)
u = Range(g, e).Address(0, 0)
Set f = e.Offset(1)
Set e = e.End(4)
Set x = f.Offset(-4, -10)
Store = "Bloomingdales*"
f.Formula = "=IF("& x &" = "&Store&",Sum(" & u & "),Sumif(A:A," & x.Address & ", K:K))"'Error
Loop Until e.Row = Rows.Count
End Sub
Please let me know if you need more info. Cheers!