Can anyone tell me what I'm missing - can't seem to find why I'm getting a compile error "Else without If". The compiler highlights the "ElseIf" line.
i = 2
Do While ws_targets.Cells(i, 2) <> ""
If Not (IsError(Application.Match(Val(ws_targets.Cells(i, ncol)), ws_wf_pivot.Range("A2").CurrentRegion.Columns(1), 0))) Then
nrow4 = Application.Match(Val(ws_targets.Cells(i, ncol)), ws_wf_pivot.Range("A2").CurrentRegion.Columns(1), 0) 'nrow4 is col in pivot table where WB ID matches
ws_targets.Cells(i, ncol1) = ws_wf_pivot.Cells(nrow4, 2) 'waterfall name
If wf.CountIf(ws_targets.Range(ws_targets.Cells(1, ncol), ws_targets.Cells(i - 1, ncol)), ws_targets.Cells(i, ncol)) = 0 Then 'If the Target ID has not been encountered
ws_targets.Cells(i, ncol2) = ws_wf_pivot.Cells(nrow4, 3) '2019 Awards
ws_targets.Cells(i, ncol2 + 1) = ws_wf_pivot.Cells(nrow4, 4) '2020 Awards
If ws_targets.Cells(i, ncol4) = ws_wf_pivot.Cells(nrow4, 1) Then 'If Cognos Node is same in WF and Targets
With ws_targets.Cells(i, ncol4)
.Interior.Color = RGB(248, 248, 248)
.Font.Color = RGB(0, 0, 0)
ElseIf ws_targets.Cells(i, ncol4) = "" Then 'Cognos Node blank in Targets spreadsheet
With ws_targets.Cells(i, ncol4)
.Value = ws_wf_pivot.Cells(nrow4, 1)
.Interior.Color = grey_fill
.Font.Color = green_font
Else: 'Cognos Node different in WF and Targets (purple font)
With ws_targets.Cells(i, ncol4)
.Value = ws_wf_pivot.Cells(nrow4, 1)
.Interior.Color = grey_fill
.Font.Color = purple_font
End If 'formating Waterfall ID
End If 'first encounter of target ID
End If 'target ID exists in Pivot table
i = i + 1 ' next row in Targets worksheet
Loop
- Appreciate any help! Ann
i = 2
Do While ws_targets.Cells(i, 2) <> ""
If Not (IsError(Application.Match(Val(ws_targets.Cells(i, ncol)), ws_wf_pivot.Range("A2").CurrentRegion.Columns(1), 0))) Then
nrow4 = Application.Match(Val(ws_targets.Cells(i, ncol)), ws_wf_pivot.Range("A2").CurrentRegion.Columns(1), 0) 'nrow4 is col in pivot table where WB ID matches
ws_targets.Cells(i, ncol1) = ws_wf_pivot.Cells(nrow4, 2) 'waterfall name
If wf.CountIf(ws_targets.Range(ws_targets.Cells(1, ncol), ws_targets.Cells(i - 1, ncol)), ws_targets.Cells(i, ncol)) = 0 Then 'If the Target ID has not been encountered
ws_targets.Cells(i, ncol2) = ws_wf_pivot.Cells(nrow4, 3) '2019 Awards
ws_targets.Cells(i, ncol2 + 1) = ws_wf_pivot.Cells(nrow4, 4) '2020 Awards
If ws_targets.Cells(i, ncol4) = ws_wf_pivot.Cells(nrow4, 1) Then 'If Cognos Node is same in WF and Targets
With ws_targets.Cells(i, ncol4)
.Interior.Color = RGB(248, 248, 248)
.Font.Color = RGB(0, 0, 0)
ElseIf ws_targets.Cells(i, ncol4) = "" Then 'Cognos Node blank in Targets spreadsheet
With ws_targets.Cells(i, ncol4)
.Value = ws_wf_pivot.Cells(nrow4, 1)
.Interior.Color = grey_fill
.Font.Color = green_font
Else: 'Cognos Node different in WF and Targets (purple font)
With ws_targets.Cells(i, ncol4)
.Value = ws_wf_pivot.Cells(nrow4, 1)
.Interior.Color = grey_fill
.Font.Color = purple_font
End If 'formating Waterfall ID
End If 'first encounter of target ID
End If 'target ID exists in Pivot table
i = i + 1 ' next row in Targets worksheet
Loop