Number Format

  • Thread starter Thread starter Lionel Fridjhon
  • Start date Start date
L

Lionel Fridjhon

I have variable that is declared as Long. When I use the
variable in an If statement such as
"If cells(r,c)=variable then"
I get the cell as a number but the variable insists on
appearing in quotes, indicating a string. As a result
the If statement comes out false.

Example If 2501 = "2501" then is false
How can I ensure that the variable is represented as a
number in the if statement so that thje answer is True?

Lionel
 
Hi
try something like
IF CLng(cells(r,c).value)=variable then
 
Can you post your code? A Long would never appear as a String. There must be
some confusion in the code that you have missed.

You could coerce the String to a Long using CLng but that really should not
be necessary with the proper declaration.
 
When you say the variable appears in quotes, where are you seeing it in
quotes?

try this before the if statement

msgbox cells(r,c).Value & "<-->" & variable & " " & cells(r,c).value =
variable
 

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

Back
Top