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

The compile error may be because of the name of the variable "str", try with
str1, for example.
About functions to play with text, try LEFT, MID or RIGHT. In this case,
LEFT can be the best one.

You can use Regular Expresions in VBA, just add the reference for "Microsoft
VBScript Regular Expresions 5.5"

Hope this helps,
Miguel.

"Samuel" wrote:

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