Add one more variable to an equation VBA

zack8576

Active Member
Joined
Dec 27, 2021
Messages
271
Office Version
  1. 365
Platform
  1. Windows
part of my macro has this equation:
it counts the number of Base, Riser, Cone, TS ( these are in column K), if column O contains Sanitary.
What if I want to add one more variable where this equation counts These items ONLY when there is also the number 4 present in column K ?
any help is appreciated
VBA Code:
            n = n + Application.Sum(Application.SumIfs(Range("C" & sr & ":C" & lr), Range("K" & sr & ":K" & lr), _
            Array("*Base*", "*Riser*", "*Cone*", "*TS*"), Range("O" & sr & ":O" & lr), "*SANITARY*"))
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
part of my macro has this equation:
it counts the number of Base, Riser, Cone, TS ( these are in column K), if column O contains Sanitary.
What if I want to add one more variable where this equation counts These items ONLY when there is also the number 4 present in column K ?
any help is appreciated
VBA Code:
            n = n + Application.Sum(Application.SumIfs(Range("C" & sr & ":C" & lr), Range("K" & sr & ":K" & lr), _
            Array("*Base*", "*Riser*", "*Cone*", "*TS*"), Range("O" & sr & ":O" & lr), "*SANITARY*"))
nvm, I added another Range in front of the range with the array and it is working fine now :)
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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