Highlight Cell If

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Good morning

Is there a way to highlight a cell if there are more than 2 letters following the number in a string.

Before

101po
A 1002pore
1003ro Next
1004pos End
A 1006po
1002pow

<tbody>
</tbody>


After

1001po
A 1002pore
1003ro Next
1004pos End
A 1006po
1002pow

<tbody>
</tbody>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG19Jun35
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Sp [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Sp [COLOR="Navy"]In[/COLOR] Split(Dn.Value, " ")
        [COLOR="Navy"]If[/COLOR] Sp Like "####[A-Za-z][A-Za-z][A-Za-z]*" [COLOR="Navy"]Then[/COLOR]
            Dn.Font.Bold = True
            [COLOR="Navy"]Exit[/COLOR] For
        [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Sp
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
If the preceding digits to the number is only 2 or 3, should i amend like "###[A-Za-z][A-Za-z][A-Za-z]*" or "##[A-Za-z][A-Za-z][A-Za-z]*"
 
Upvote 0
You're welcome
NB:- Yes change the hashes "#" count to the number you require required
 
Upvote 0
If you can, also looking to highlight cells where there is

1. no characters following the numeral
2. One character following the numeral.
 
Upvote 0
Below is an example of the previous request

1. There are no characters between the numeral & the space

2. One character between the numeral & the space

BeforeAfter
A 101 EndA 101 End
B 1002s PoB 1002s Po

<tbody>
</tbody>

Thank You

 
Last edited:
Upvote 0
Does this macro do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub HighlightIfNotTwoLetters()
  Dim Dn As Range
  For Each Dn In Range("A1", Cells(Rows.Count, "A").End(xlUp))
    Dn.Font.Bold = Not " " & Dn & " " Like "*####[A-Za-z][A-Za-z] *"
  Next
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Works perfect. If I needed to highlight the cells if one character between the numeral & the space how could this be achieved?
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,031
Members
448,940
Latest member
mdusw

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