VBA to count rows based on two columns values

rosscortb

New Member
Joined
Mar 10, 2015
Messages
8
Hello

I can't work this out. I want to count the rows but only if the column M equals Asset Mgt and column N equals Business Dev. How do I add the column n piece please?
Thank

Ross



Code:
With Sheets("Asset Mgt")
Counts = Application.CountIf(.Range("M:M"), "Asset Mgt"






MsgBox Counts
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Re: Help using vba to count rows based on two columns values

something along the lines of
Dim c As Range, rng
Dim lr As Long
Dim asset_mngmnt As Integer

lr = Range("m" & Rows.Count).End(xlUp).Row
Set rng = Range("m1:m" & lr)
For Each c In rng
If c.Value = "Asset Mgt" And c.Offset(0, 1).Value = "Business Dev" Then
asset_mngmnt = asset_mngmnt + 1
End If
Next c
Range("o1") = asset_mngmnt
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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