Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile error: NEXT without FOR

Status
Not open for further replies.

gwoman

Programmer
Nov 16, 2004
199
US
Below is the a portion of code from a procedure I wrote and it keeps throwing a compile error: NEXT without FOR ...
Apparently I'm missing something ... can anyone see something I may be missing .... thanks so much!
~gwoman

For Each itm In ritms

If itm.Class = olAppointment Then
i = i + 1

'j is the column number
j = 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtCoFacilitatorName") <> "" Then
rng.Value = itm.UserProperties("txtCoFacilitatorName")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtCostAvoidance") <> "" Then
rng.Value = itm.UserProperties("txtCostAvoidance")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtCostReduction") <> "" Then
rng.Value = itm.UserProperties("txtCostReduction")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtEventShortDescription") <> "" Then
rng.Value = itm.UserProperties("txtEventShortDescription")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtFreeText") <> "" Then
rng.Value = itm.UserProperties("txtFreeText")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtHyperlinkEventFolder") <> "" Then
rng.Value = itm.UserProperties("txtHyperlinkEventFolder")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtHyperlinkScopingDoc") <> "" Then
rng.Value = itm.UserProperties("txtHyperlinkScopingDoc")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtImprovementArea") <> "" Then
rng.Value = itm.UserProperties("txtImprovementArea")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtKaizenFacilitator") <> "" Then
rng.Value = itm.UserProperties("txtKaizenFacilitator")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtKaizenStatus") <> "" Then
rng.Value = itm.UserProperties("txtKaizenStatus")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtLDTPresent") <> "" Then
rng.Value = itm.UserProperties("txtLDTPresent")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("txtProcessTeam") <> "" Then
rng.Value = itm.UserProperties("txtProcessTeam")
j = j + 1


Set rng = wks.Cells(i, j)
If itm.UserProperties("txtQuarterOccuring") <> "" Then
rng.Value = itm.UserProperties("txtQuarterOccuring")
j = j + 1

Set rng = wks.Cells(i, j)
If itm.UserProperties("chkBoxReminder") <> "" Then
rng.Value = itm.UserProperties("chkBoxReminder")
j = j + 1

Set rng = wks.Cells(i, j)
On Error Resume Next
End If
j = j + 1
End If
i = i + 1
Next itm
 
In fact, a LOT of missing End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



Hi,

Each If...Then needs an End If.

You are missing quite a few.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You need to close out ALL of those IFs. By my count, your IFs go 15 deep, and you only End If twice.

Perhaps you forgot to use an underscore to continue your IFs which allows them to function without an End If?
Code:
            If itm.UserProperties("txtCoFacilitatorName") <> "" Then [highlight]_[/highlight]
                    Rng.Value = itm.UserProperties("txtCoFacilitatorName")

Also, have a look at Smart Indenter, a free addin. It makes this kind of structure very easy to follow.

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
anotherhiggins: "Also, have a look at Smart Indenter, a free addin. "

Indeed. Indenter is great to use as it does exactly as you say - makes structure much easier to follow.

I would also recommend looking at MZ-Tools, which is also free. If you are in the VBE even casually, this is a fabulous addin. If you do even a moderate amount of coding, it will become essential. To be able to insert common code snippets with a single keystroke...well, I just love it.

Gerry
 
Thanks everyone ... appreciate it!
Have a good one!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top