# How to Use VBA Sumifs with Multiple Criteria in Same Column

Excel is the most widely used tool for dealing with massive datasets. We can perform myriads of tasks of multiple dimensions in Excel. In this article, I will show you how to use VBA SUMIFS with multiple criteria in the same column.

## Use VBA Sumifs with Multiple Criteria in Same Column: 3 Easy Steps

This is the dataset for todayâ€™s article. There are some orders with the Price. I will calculate the price if the product is Mobile or AC. The SUMIFS function is useful here. However, I will illustrate how to use Sumifs using VBA macro here.

### Step 1: Create New Module in Visual Basic Window

The first step is to create a new module.

• First of all, go to the Developer.
• Then, select Visual Basic.

• A VBA window will appear. Go to the Insert.
• After that, select Module.

• Excel will create a new module.

### Step 2: Write Down VBA Macro Code

The next step is to write down the VBA code. For this,

• Go to the new module and write down the following code
``````Sub Sumifs_same_column_multiple_criteria()
Total = 0
'Apply For loop
For n = 5 To 11
If Range("C" & n) = "Mobile" Or Range("C" & n) = "AC" Then
Total = Total + Range("D" & n)
End If

Next n
'Show Result
Range("C13") = Total
End Sub``````

Code Breakdown:

• First of all, I have created a sub-procedure Sumifs_same_column_multiple_criteria()
• Then, I set the value for Total to be 0.
• After that, I applied a For loop for the Total.
• Then, I set the criteria using the IF statement
• n defines the row number here.
• Finally, I showed the result in C13.

### Step 3: Run VBA Macro to Apply Multiple Criteria in Same Column

Finally, I will run the VBA macro. To do so,

• Select the icon (see the image below).

• Excel will run the code and show the result.

## Things to Remember

• You can press ALT+F11 to bring the Visual Basic Window.
• You can press F5 to run the code.

## Conclusion

In this article, I have explained how to use VBA Sumifs with multiple criteria in the same column. I hope it helps everyone. If you have any suggestions, ideas, or feedback, please feel free to comment below.

## Related Articles

<< Go Back to Excel SUMIFS with Multiple Criteria | Excel SUMIFS Function | Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Akib Bin Rashid

AKIB BIN RASHID, a materials and metallurgical engineer, is passionate about delving into Excel and VBA programming. To him, programming is a valuable time-saving tool for managing data, files, and internet-related tasks. Proficient in MS Office, AutoCAD, Excel, and VBA, he goes beyond the fundamentals. Holding a B.Sc in Materials and Metallurgical Engineering from Bangladesh University of Engineering and Technology, MD AKIB has transitioned into a content development role. Specializing in creating technical content centred around Excel and... Read Full Bio

We will be happy to hear your thoughts

Advanced Excel Exercises with Solutions PDF