must be too simple

M

Marie Lavoie

Hi.
I've programmed A BIT in VB before, but never with Excel. And i'm really
having trouble with a stupid thing. To indicate a cell to excel...
I only want him to read the value of a cell!
A sort of:

If Main!A5= "CLS" Then
....
....
End If

How to I write this "Main!A5" ??

Thank you.

Marie
 
E

Ed

Hi, Marie. Are you trying to read the value of the cell with Visual Basic,
or with an Excel VBA macro?

Ed
 
B

Bob Kilmer

Marie,
'Sheets("Main").Range("A5")', properly speaking, is a Range object (the
cell), not a String (the text the cell displays). Using
'Sheets("Main").Range("A5") = "CLS"' relies on VBAs "default value" of the
Range object to return the String value of the cell. Allowing VBA to
determine whether to return the cell or the text the cell displays can be
unreliable under some not-very-rare circumstances. I recommend that you be
unambiguous and use 'Sheets("Main").Range("A5").Text' which always returns
the text the cell displays and never returns the cell.

Bob Kilmer
 
Top