View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default IF THEN ELSE in VBA

Hi CCManager,

Try:

Sub FieldTip2()
With Range("B1")

If ActiveCell.Address(0, 0) = "M3" Then
.Value = Range("K57").Value
ElseIf ActiveCell.Address(0, 0) = "M5" Then
.Value = Range("K58").Value
Else
.Value = ""
End If
End With
End Sub


---
Regards,
Norman

"CCManager " wrote in message
...
What I am trying to do:
If the user has cell M3 selected, then change cell S8 to show the data
in cell K57. If the user has cell M5 selected, change cell S8 to show
the data in cell K58...and so on.

Here is what I have that is not working.

Sub FieldTip()
If ActiveCell.Value = ("M3") Then Range("S8").Value = ("K57")
Else: If ActiveCell.Value = ("M5") Then Range("S8").Value = ("K58")
Else: Range("S8").Value = " "
End If
End Sub

Any help would be greatly appreciated.


---
Message posted from http://www.ExcelForum.com/