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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,954
Messages
6,175,601
Members
452,658
Latest member
GStorm

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