Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cells(1,1).Text <> String because???

Status
Not open for further replies.

IknowMe

Programmer
Aug 6, 2004
1,214
US
In Cells(1,1) (formatted as text) I have a value say "ABCD"

If WS.Cells(1,1).Text = "ABCD" Then
'Never getting in here
End If

What am I doing wrong?

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Nevermind, just call me a liar.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Okay I'll oblige you


LIAR LIAR PANTS ON FIRE!

Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Also, don't confuse the .Text property for the Text format. If you have a cell formatted as Text, that is different than saying Range("A1").Text. In the code scenario, the .Text property will return literally what is displayed in the cell, as opposed to it's actual value. Try it with either a custom format, or dates, etc.

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 
@ abaldwin

Thanks for humoring. I was testing a function outside of its normal environment and had a typo on my variable name. Was in a hurry and forgot 'option explicit' in my test code.

@ firefytr

Thanks for offering up the tip. I did have the cell formatted as text and was using .Text so I couldn't for the life of me figure out why I wasn't getting the Text value of the Cell, but rather kept getting "", see above for explanation.

I'm trying to get more familiar with all the cool stuff you can actually do with the cells. I have a tendancy to look at everything from a code point of view, but your posts constantly remind me to look from all directions. Thanks for your help.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top