text or numeral

  • Thread starter Thread starter Lok Tak Cheong
  • Start date Start date
L

Lok Tak Cheong

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
 
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
 
Thanks
Rick Rothstein (MVP - VB) said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top