View Single Post
 
Old 04-10-2017, 06:55 PM
Amitti Amitti is offline Windows 10 Office 2010 32bit
Novice
 
Join Date: Mar 2017
Posts: 7
Amitti is on a distinguished road
Default How can I compare a string in a cell to another string?

Hi All,

This may be a silly question but I'm really stuck and need your help.

I'm trying to compare a string in a cell to another string to see if they match but can't seem to be able to because the comparison always fails. I must be using the wrong call. Like this:


'assume i and str are declared
With ActiveDocument
str = .Tables(i).Cell(2, 1).Range.Text
Select Case str
Case "AAA"
'do something
Case "BBB"
'do something
End Select
End With

I also tried Left(str, len(str) -1) to try and get rid of the non-printable character at the end of the string in the cell but it didn't work for me either.
Is there an easy way to compare a string in a cell to another string?

Thank you in advance.
Reply With Quote