VBA Sumif Formula Help

Copper Contributor

Hello,

 

Any help/tips would be appreciated! I'm fairly green with VBA and I'm trying to repair a macro written by someone else long ago.

 

I am having difficulties getting the macro below to calculate a sumif (Import Commission Adj) and to sum two columns (Calculate Net). I am needing to sumif column F based on criteria in column G of the Macro2 tab into column I of the Macro6 tab for a variable amount of rows. Then sum columns H and I in column J in the Macro6 tab. When I run the current macro as is these two columns are blank. Code and visuals are below.

 

'Import Commission Adj


Range("I2").Select
ActiveCell.FormulaR1C1 = "=SUMIF(Macro2!C[-2],Macro6!RC[-7],Macro2!C[-3])"
If Range("A3").Value <> 0 Then
Selection.AutoFill Destination:=Range("I2:I" & Range("A1000000").End(xlUp).Row)
End If
Range("I:I").Select
Selection.Copy
Range("I1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

 

'Calculate Net


Range("J2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
If Range("A3").Value <> 0 Then
Selection.AutoFill Destination:=Range("J2:J" & Range("A1000000").End(xlUp).Row)
End If
Range("J:J").Select
Selection.Copy
Range("J1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

 

Macro2 Tab - This is the data that I want to sumif in column I of the Macro6 tab. Sum the range in column F based on criteria range in column G.

brycew51_4-1643308909131.png

 

 

Macro6 Tab - (Columns A-H are copy and pasted in a prior macro that is working properly). Criteria is in column B. Wanting to sumif data in Macro2 tab into column I of this tab. Then sum H and I in column J of this tab.

brycew51_5-1643308952292.png

 

 

 

 

0 Replies