Trouble with Elseif command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all...

trying to run the following simple program but it will not run. Have tried
the offline help and followed the example to the letter but with no luck.
Any ideas would be appreciated.


Sub ContractHighlight()
'
' ContractHighlight Macro
' Macro recorded 23/11/2004 by Keith Holden
'

'If h4 >1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 3

ElseIf i4 > 1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 2

End If
End Sub
 
'If range("h4").value >1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 3

ElseIf range("i4").value > 1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 2

End If
End Sub
 
"if" was commented by mistake .

remove the comment
try this

Sub ContractHighlight()
'
' ContractHighlight Macro
' Macro recorded 23/11/2004 by Keith Holden
'

If h4 >1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 3

ElseIf i4 > 1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 2

End If
End Su
 
try
Sub aa()
With Range("a4:m4").Interior
If Range("h4") > 1 Then
.ColorIndex = 3
ElseIf Range("i4") > 1 Then
..ColorIndex = 0
'Else 'do what??
'.ColorIndex=???
End If
End With
End Sub
 
Keith said:
Hello all...

trying to run the following simple program but it will not run. Have tried
the offline help and followed the example to the letter but with no luck.
Any ideas would be appreciated.


Sub ContractHighlight()
'
' ContractHighlight Macro
' Macro recorded 23/11/2004 by Keith Holden
'

'If h4 >1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 3

ElseIf i4 > 1 Then
Range("A4:M4").Select
Selection.Interior.ColorIndex = 2

End If
End Sub

If you mean it will not go to the elseif part then it is probably
because the first part was true and therefore never went to the elseif
part.

-Pete
 

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