highlighting numbers in tens position

rzml

New Member
Joined
Dec 24, 2020
Messages
40
Office Version
  1. 2016
Platform
  1. Windows
Hi,
looking for a vba code that will highlight the numbers in a range of cells containing 3,4,8 or 9 in the Tens position.
Thanks for the help.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You could do that with simple conditional formatting using a rule of
Excel Formula:
=OR(MOD(INT(A1/10),10)={3,4,8,9})
where A1 is the cell to highlight.
 
Upvote 0
thanks for your answer jasonb, but i need this to be done for selected cells such as below
 

Attachments

  • 1608806595139.png
    1608806595139.png
    57.2 KB · Views: 9
Upvote 0
You could still do it the same way, with the range selected in your example above you just need to change A1 to M2 in the formula then apply it to the whole range.
 
Upvote 0
it gave an error message
 

Attachments

  • thanks.png
    thanks.png
    127.8 KB · Views: 4
Upvote 0
That's my bad, I was sure that the method could be used in CF but not in data validation.
Try this one instead (I haven't tested this but it should work, it doesn't use any of the methods that are not permitted).
Excel Formula:
=CHOOSE(MOD(INT(A1/10),10)+1,,,,1,1,,,,1,1)
 
Upvote 0
it didn't give an error but nothing happened
 
Upvote 0
Using a random number list, it works for me.
Book1
M
247
343
450
523
643
723
842
918
1092
1137
1212
1341
1444
1558
1691
1768
184
1948
2074
2196
2292
2322
Sheet3
 
Upvote 0
Solution
oh yes, it did thanks. if I want it to highlight the numbers ones position how can I change the formulae?
 
Upvote 0
Actually, a slightly easier to follow formula, the position is set by the division part of the formula
ones (see note below)
Excel Formula:
=SEARCH(MOD(INT(M2/1),10),"3489")
tens
Excel Formula:
=SEARCH(MOD(INT(M2/10),10),"3489")
hundreds
Excel Formula:
=SEARCH(MOD(INT(M2/100),10),"3489")
Note that INT and the division part are not necessary for the ones formula but I've left them in so that it is easier to follow. This one could be changed to
Excel Formula:
=SEARCH(MOD(M2,1),"3489")
and it would still work the same.
 
Upvote 0

Forum statistics

Threads
1,215,494
Messages
6,125,137
Members
449,207
Latest member
VictorSiwiide

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