PDA

View Full Version : very trivial one - if else condition



sharath
09-29-2005, 10:19 AM
Hi All,

The .bas(macro) is having following code

For i = ArraySize To 1 Step -1
If BarReport = 3 Then
For j = 1 To NoOfGroups Step 1
Else
For j = NoOfGroups To 1 Step -1
End If
dsChart.Cells(j + 1, i + 1).Value = DataArr(loopCnt)
loopCnt = loopCnt - 1
Next j
Next i

When I'm executing above code, the program throwing compile error "Else without If"

Can someone please let me know how to correct this problem.

Regards,
Sharath.

Jacob Hilderbrand
09-29-2005, 10:27 AM
Is this what you are trying to do?


For i = ArraySize To 1 Step -1
If BarReport = 3 Then
For j = 1 To NoOfGroups Step 1
dsChart.Cells(j + 1, i + 1).Value = DataArr(loopCnt)
loopCnt = loopCnt - 1
Next j
Else
For j = NoOfGroups To 1 Step -1
dsChart.Cells(j + 1, i + 1).Value = DataArr(loopCnt)
loopCnt = loopCnt - 1
Next j
End If
Next i


The problem is that you have the Ifs and For statements mixed together.