Count if But the is the last two letters=CD

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,201
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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,215,831
Messages
6,127,144
Members
449,363
Latest member
Yap999

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