Property of a cell with a string

S

Slim Slender

If .Cells(myRow, myColumn).???? = "String"
Then

What property of cells do I need here? Value gives an error.
Auto List Members, List properties/Methods won't work for me. They are
turned on in Options but I can't get any help.
 
G

GS

After serious thinking Slim Slender wrote :
If .Cells(myRow, myColumn).???? = "String"
Then

What property of cells do I need here? Value gives an error.
Auto List Members, List properties/Methods won't work for me. They are
turned on in Options but I can't get any help.

..Value is default; .Text may be an option; -neither are needed here!

Try using a var to put the cell contents into, then test the var.

Dim vTemp As Variant

'Get the cell contents
vTemp = Cells(myRow, myColumn)

'Test the cell contents
If vTemp = "String" Then...
 
J

Jim Cone

Try this with text in B5 and with a number in B5 Then run it with and without ".Value"
....
Don't place any bets ahead of time. <g>
'---
Sub xyz()
Dim myType As String
myType = TypeName(Cells(5, 2).Value)

If myType = "String" Then
MsgBox myType
Else
MsgBox "Not a string, it is a " & myType
End If
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(Extras for Excel add-in: convenience built-in)





"Slim Slender" <[email protected]>
wrote in message
news:9d798d8e-2d4c-455e-a56c-92ed548e676e@v17g2000vbo.googlegroups.com...
 
S

Slim Slender

Thanks for the responses. Turned out all I had to do was specify the
column.

If .Cells(myRow, myColumn).Value = "String" Then doesn't
work, but

If .Cells(myRow, 5).Value = "String" Then works just
fine.

This is what I wanted in the first place but I was working with cloned
code
and hadn't completely adapted it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top