VBA Countifs where left of cell is tested?

raven_squire

Board Regular
Joined
Jan 13, 2013
Messages
99
Hello,

I have the code below that works as intended (except the last condition matches with Bananas for simplicity). I need to change it so that in adition to existing criteria it counts all alarms starting with "Ban". So it would count all the alarms for "Bananas", "Bandanas", "Bankrupt" etc etc etc I dont know how many different kinds of alarms start with "Ban". I dont know how to alter the cells in the range before comparing them. Any help would be apreciated.

Worksheets("Statistics").Cells(28, 2).Value = Application.WorksheetFunction.CountIfs(Worksheets("AlarmListing").Range("Table1[Date]"), ">=" & _
startDate, Worksheets("AlarmListing").Range("Table1[Date]"), "<=" & endDate _
, Worksheets("AlarmListing").Range("Table1[[Alarm Type]]"), "Bananas")


Thankyou
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello,

Have you tried to replace "Bananas" by "Ban" & "*" ... ?

HTH
 
Upvote 0
Thank you for that :-)

It had not occured to me to use a wild card and when I tested it it worked a treat.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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