ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   text or numeral (https://www.excelbanter.com/excel-programming/391662-text-numeral.html)

Lok Tak Cheong

text or numeral
 
I am a newbie in excel VBA.
I attempt to set a condition to test cells property.
1. The cell have 5 characters
2. The first 2 characters are letters
3. The last 3 characters are numeral




Rick Rothstein \(MVP - VB\)

text or numeral
 
I am a newbie in excel VBA.
I attempt to set a condition to test cells property.
1. The cell have 5 characters
2. The first 2 characters are letters
3. The last 3 characters are numeral


Test the contents of your Cell like this...

If ContentsOfCell Like "[a-zA-Z][a-zA-Z]###" Then
' cell contents are 2 letters followed by 3 numbers
End If

Rick

Lok Tak Cheong

text or numeral
 
Thanks
"Rick Rothstein (MVP - VB)" wrote in
message ...
I am a newbie in excel VBA.
I attempt to set a condition to test cells property.
1. The cell have 5 characters
2. The first 2 characters are letters
3. The last 3 characters are numeral


Test the contents of your Cell like this...

If ContentsOfCell Like "[a-zA-Z][a-zA-Z]###" Then
' cell contents are 2 letters followed by 3 numbers
End If

Rick





All times are GMT +1. The time now is 08:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com