View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Norman Jones
 
Posts: n/a
Default Substring in excel? How about regular expressions?

Hi Samuel,

Try:

Dim sStr As String

sStr = ActiveSheet.Cells(r, c).Value

If Left(sStr, 3) = "USA" Then
'Do something
End If


---
Regards,
Norman



"Samuel" wrote in message
oups.com...
I need to act upon the test "USA" found in the first three chars of a
cell.
This is what I did, but I get a compile error..
So I did something wrong. How do I copare against specifc characters?
Even better, can I use regular expressions?

str = ActiveSheet.Cells(r, c)
check = substr(str, 1, 3)
If (check = "USA") Then
' do something
End If