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 IsNumber question

Hi Patrick,

"Patrick Simonds" wrote in message
...
I need a formula which will look at cell D3, and if the formula has
returned a number then execute the following code:

Range("D9:F9").Select
Selection.Interior.ColorIndex = 35


A formula cannot change the format of another cell.

If you want to use VBA, try:

'============
Public Sub aTester()
Dim rng As Range

Set rng = Selection

With rng.Interior
If Application.IsNumber(Range("D3")) Then
.ColorIndex = 35
Else
.ColorIndex = 0
End If
End With

End Sub
'<<============


---
Regards,
Norman