Thread: Newbie IF
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
SmilingPolitely SmilingPolitely is offline
external usenet poster
 
Posts: 18
Default Newbie IF

This is because you are asking Excel to compare the two strings "d237"
and "d239", which of course are not equal so the code will return 2.

I am pretty sure that yuo want to be comparing the values of the cells:

If Range("d237").Value = Range("d239").Value Then
Range("d241").Value = "1"
Else
Range("d241").Value = "2"
End If



Hope this helps.... and don't work late!


Scott


Jeff wrote:

I know I'm new to VB but this seems pretty simple and I'm
stuck.
I hate to ask dumb questions here but I've been looking at
this for an hour! Maybe it's late in the evening...

If ("d237" = "d239") Then
Range("d241").Value = "1"
Else
Range("d241").Value = "2"
End If

I'm returning "2" but it shouldn't be. Currently d237 does
equal d239. The only thing I can think of that could be
causing a problem is d237 is a formula and d239 is a cell
reference to another sheet.