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 Can a Macro contain an IF statement? How?

Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.