Thread: Compile error
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Compile error

Thanks Joe it worked but now I need to add another Elself statement which is:

If cells F102 and G102 remain equal, then Range("A105").Value =
Range(J102)Range(K102),Range(E102),Range(H102).

Will you please tell me how to write this statement and where I have to
insert it.

Again thank you so much.

"Joe User" wrote:

"MAX" wrote:
I am writing this code (below) and a window appears
with Compile error and Syntax error.


I suspect that your error is due to an explicit line break without the
necessary continuation character. But it is difficult to say for sure since
it is difficult to discern which line breaks in your posting are due to text
wrapping in the message v. what you actually entered in the VBA enter.

In summary, VBA statements must be a "single" line. Long lines can be
continued by putting an underscore (_) at the end, but only after a space;
ergo, only where a space is valid in the statement.

The following should work "for sure", keeping lines short enough to avoid
line wrapping in the message (I hope):

Range("A105").Value = _
IIf(Range("F102") = Range("G102"), Range("A99"), _
IIf(Range("F102") Range("G102"), Range("E102"), _
Range("H102")))


----- original message -----

"MAX" wrote:
Hello
I am writing this code (below) and a window appears with Compile error and
Syntax error. I am having also this part of the code highlighted.
Range("A105").Value = IIf(Range("F102") = Range("G102"), Range("A99"),
IIf(Range("F102") Range("G102"), Range("E102"),

This is the code:
Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"


If Range("A105").Interior.ColorIndex =4 Then
Range("A105").Interior.ColorIndex = 6
Range("A105").Value = IIf(Range("F102") = Range("G102"),
Range("A99"), IIf(Range("F102") Range("G102"), Range("E102"),

Range("H102")))
ElseIf Range("A105").Interior.ColorIndex = 6 Then
Range("A105").Interior.ColorIndex = 4
Range("A105").Value = "WORLD CHAMPIONS 2010"
End If
End Sub

I appriciate even a small help.
Thanks in advance.