jasonprescott
New Member
- Joined
- Apr 2, 2020
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
Hello guys,
I have this code of mine in the Macro (And yea, I tried using the classis "i" as a variable, did not work so I changed it to "g")
The problem is, after the first IF matches the condition, it does the "First step done" and then it goes automatically to the "End Sub" no nevertheless there still is some other code after this FOR loop.
I have this code of mine in the Macro (And yea, I tried using the classis "i" as a variable, did not work so I changed it to "g")
VBA Code:
For g = 1 To 20
If (InStr(1, salesWS.Cells(g, 2).Value, "X004a", 1) > 0 And InStr(1, salesWS.Cells(g, 3).Value, "TOBI", 1) > 0 And InStr(1, salesWS.Cells(g, 4).Value, "PLN", 1) > 0) Then
pivotWS.Cells(9, 10).Value = salesWS.Cells(g, 5).Value 'FIRST STEP DONE
pivotWS.Cells(9, 11).Value = -Abs(salesWS.Cells(g, 7).Value) 'SECOND STEP SKIPPED
ElseIf (InStr(1, salesWS.Cells(g, 2).Value, "X004a", 1) > 0 And InStr(1, salesWS.Cells(g, 3).Value, "TOBI", 1) > 0 And InStr(1, salesWS.Cells(g, 4).Value, "EUR", 1) > 0) Then
pivotWS.Cells(9, 12).Value = salesWS.Cells(g, 5).Value
pivotWS.Cells(9, 13).Value = -Abs(salesWS.Cells(g, 7).Value)
ElseIf (InStr(1, salesWS.Cells(g, 2).Value, "X004c", 1) > 0 And InStr(1, salesWS.Cells(g, 3).Value, "TOBI", 1) > 0 And InStr(1, salesWS.Cells(g, 4), "PLN", 1) > 0) Then
pivotWS.Cells(11, 10).Value = salesWS.Cells(g, 5).Value
pivotWS.Cells(11, 11).Value = -Abs(salesWS.Cells(g, 7).Value)
ElseIf (InStr(1, salesWS.Cells(g, 2).Value, "X004c", 1) > 0 And InStr(1, salesWS.Cells(g, 3).Value, "TOBI", 1) And InStr(1, salesWS.Cells(g, 4).Value, "EUR", 1) > 0) Then
pivotWS.Cells(11, 12).Value = salesWS.Cells(g, 5).Value
pivotWS.Cells(11, 13).Value = -Abs(salesWS.Cells(g, 7).Value)
End If
Next
The problem is, after the first IF matches the condition, it does the "First step done" and then it goes automatically to the "End Sub" no nevertheless there still is some other code after this FOR loop.