Forum Discussion
Formula to find specific random text in a cell
- Feb 16, 2021
SEARCH accepts * and ? as wildcards, but not #.
If you use Excel on Windows, you can use a custom VBA function:
Function Check(s As String) As Boolean Dim re As Object Set re = CreateObject("VBScript.RegExp") re.Pattern = "[A-Za-z]{2}[0-9] to [A-Za-z]{2}[0-9]" Check = re.Test(s) End Function
Let's say you want to apply conditional formatting to cells in column B, starting in B2.
Use the following formula in your conditional formatting rule:
=Check(B2)
Don't forget to save the workbook as a macro-enabled workbook, and make sure that you allow macros when you open it.
SEARCH accepts * and ? as wildcards, but not #.
If you use Excel on Windows, you can use a custom VBA function:
Function Check(s As String) As Boolean
Dim re As Object
Set re = CreateObject("VBScript.RegExp")
re.Pattern = "[A-Za-z]{2}[0-9] to [A-Za-z]{2}[0-9]"
Check = re.Test(s)
End Function
Let's say you want to apply conditional formatting to cells in column B, starting in B2.
Use the following formula in your conditional formatting rule:
=Check(B2)
Don't forget to save the workbook as a macro-enabled workbook, and make sure that you allow macros when you open it.
- Tez_ClewsFeb 16, 2021Copper Contributor
Works perfectly thank you,
I thought VBA was the way to go as used it in another project but still very much a novice, was not aware of conditional format to VBA linking.
Managed to adapt it for different criteria so thank you again