This is the sample dataset.
Step 1 – Create a New Module in Visual Basic Window
- Select Developer.
- Choose Visual Basic.
- In the VBA window, select Insert.
- Select Module.
A new module is created.
Read More: SUMIFS with Multiple Criteria in the Same Column
Step 2 – Enter the VBA Macro Code
- Use the following code in the new module:
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:
- creates a sub-procedure: Sumifs_same_column_multiple_criteria()
- sets the value of Total to 0.
- a For loop is used for the Total.
- the criteria are set using the IF statement
- n defines the row number.
- the result is displayed in C13.
Step 3 – Run the VBA Macro to Apply Multiple Criteria in the Same Column
- Select the icon shown below.
Excel will run the code and show the result.
Read More: How to Use SUMIFS with Multiple Criteria in the Same Column
Things to Remember
- You can also press ALT+F11 to open the Visual Basic Window.
- You can press F5 to run the code.
Download Practice Workbook
Download this workbook.
Related Articles
- Excel SUMIFS with Multiple Vertical and Horizontal Criteria
- How to Apply SUMIFS with Multiple Criteria in Different Columns
- SUMIFS with Multiple Criteria Along Column and Row in Excel
- How to Apply SUMIFS with INDEX MATCH for Multiple Columns and Rows
- SUMIFS: Sum Range Across Multiple Columns
- Exclude Multiple Criteria in Same Column with SUMIFS Function
<< Go Back to Excel SUMIFS with Multiple Criteria | Excel SUMIFS Function | Excel Functions | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!