How can I; COUNTIF(C4:G4,"compare last digit only of values in range to Criteria cell)

Poker Joe

New Member
Joined
Feb 12, 2015
Messages
30
Office Version
  1. 2019
Platform
  1. Windows
I'd like to enter a formula in I9 and drag it across to R9, go through and change the references and drag it down 650 rows.
A macro would be nice but I'll take a formula if I can get the right functions to give me what I need.

I've tried several formulas to no avail.

=COUNTIF(C4:G4,"*"&I9)
=COUNTIF(C4:G4,"*"&TEXT(I9,"0"))
=COUNTIF(C4:G4,"*"&TEXT(I9,"0")&"")
=COUNTIF(C4:G4,"*"&TEXT(I9,"0")&"$")

Last Digit Reference
IDDateMTWThF0123456789
104/25/2021da9kl16mb8ys6ql31211
204/26/2021ab2ab3ave5mb12ql3221
304/27/2021ve9pl5th5mb12ys41121
404/28/2021ab2ve7pl6mb10ql3
504/29/2021da8kl16pl4mb8ys5
604/30/2021ab2ve9da7pl6pl7
705/01/2021ab2ve8th6th9ys4
805/02/2021ve7ve8da8th5ys6
905/03/2021ab4ab5th6mb10ql3
1005/04/2021ab4kl12th9ys5ys6
1105/05/2021da9kl14kl15pl3pl5
1205/06/2021ab4pl4pl6mb10ys7
1305/07/2021da9th6th9mb10ql4
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How about
Fluff.xlsm
ABCDEFGHIJKLMNOPQR
1
2Last Digit Reference
3IDDateMTWThF0123456789
4144311da9kl16mb8ys6ql30001002011
5244312ab2ab3ave5mb12ql30022010000
6344313ve9pl5th5mb12ys40010120001
7444314ab2ve7pl6mb10ql3
8544315da8kl16pl4mb8ys5
9644316ab2ve9da7pl6pl7
10744317ab2ve8th6th9ys4
11844318ve7ve8da8th5ys6
12944319ab4ab5th6mb10ql3
131044320ab4kl12th9ys5ys6
141144321da9kl14kl15pl3pl5
151244322ab4pl4pl6mb10ys7
161344323da9th6th9mb10ql4
Main
Cell Formulas
RangeFormula
I4:R6I4=COUNTIF($C4:$G4,"*"&I$3)
 
Upvote 0
That works fine on my XLBB worksheet but I have another workbook with a similar worksheet and the formula doesn't work on that one.
The format of all the cells is General. Now, some of the cells have values generated by a macro and these cells are referenced in the range part of the formula.

That formula works but for some reason in the workbook/worksheet I want to use it in, it returns a value of zero for cells that have the same last digit value as the criteria cell in the CountIf function.
 
Upvote 0
Are all the values text strings, or are they numbers?
 
Upvote 0
That's why it doesn't work. Using wildcards only works with text.
If your values are numbers why did you post data that is text?
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT(--(RIGHT($C4:$G4,1)=I$3&""))
 
Upvote 0
Solution
How about
Excel Formula:
=SUMPRODUCT(--(RIGHT($C4:$G4,1)=I$3&""))
Hmmm...sorry, I didn't realize it made a difference. I already had that XLBB spreadsheet open using it for another project question, so I used it. I'm having trouble utilizing XLBB in the workbook I'm currently working in. I spend more time troubleshooting XLBB than working in the workbook.

The SUMPRODUCT formula works great! I appreciate it and I will duly note TEXT and NUMBERS make a difference. I knew they did for some things but wasn't aware for this question. Now, I am. Thanks!
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,159
Messages
6,123,351
Members
449,097
Latest member
thnirmitha

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