Count if But the is the last two letters=CD

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,206
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have a sheet call "Extended" which has lots of sales in it
column O is the region

however its not showing as i need
for eg it might say "Hello CD" or "Howard CD" or "TimeCD" or something complete different! but always ends with "CD" (if it doesn't i dont want to count them)
so what i need is this,
A macro that can Countif the last two Letters in each cell are "CD"

So for example


Column O
Hell CDcount
PlaceHQ
BIG House
TonyCDcount
hands of CDcount
Wow CDcount
Nothing
Me
HelpSo the count is 4
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
A macro is not necessary.

You can do it like this:
Excel Formula:
=COUNTIF(A2:A10,"*" & "CD")

If you need to do it in VBA, you can use "Application.WorksheetFunction.Countif..." to use most Excel functions in VBA.
 
Upvote 0

Forum statistics

Threads
1,217,041
Messages
6,134,162
Members
449,861
Latest member
DMJHohl

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