Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21842

Nested If returning no output

$
0
0
Hi

I have been working on the code below for a long time, but continue to get no output.
Is there an issue with the nested if... then... else coding?

Values in cells(x,18) and cells(x,19) = 0
Value in cells(x,15) = 1
Value in cells(2,3) = 5
Values in cells(2,10) = 0

I would have thought the code should have worked (one in bold below). However, it returns no output whatsoever. Can anyone assist in help solve this?

Many thanks
/|/|


Sub Row()
x=2
y=3

Sheets("TPL").Select
'Row

'when prev S? or S!>0
If Cells(x, 18) > 0 Or Cells(x, 19) > 0 Then
If Cells(y, 6) = "L" Then
Cells(y, 7) = Cells(y, 4) + 1
End If
ElseIf Cells(x, 18) > 0 Or Cells(x, 19) > 0 Then
If Cells(y, 6) = "S" Then
Cells(y, 7) = Cells(y, 5) + 1
End If
'when prev S? and S! = 0; prev A?>0
ElseIf Cells(x, 18) = 0 And Cells(x, 19) = 0 Then
If Cells(x, 15) > 0 Then
If Cells(x, 10) = Cells(2, 3) Then
Cells(y, 7) = Cells(x, 7) + 1 'when prev U = max units, add 1 to the prev row
End If
End If
ElseIf Cells(x, 18) = 0 And Cells(x, 19) = 0 Then
If Cells(x, 15) > 0 Then
If Cells(x, 10) < Cells(2, 3) Then
Cells(y, 7) = Cells(x, 7) 'when prev U not equal to max units, continue with the prev row
End If
End If

'when prev S? and S! = 0; prev A?=0
ElseIf Cells(x, 18) = 0 And Cells(x, 19) = 0 Then
If Cells(x, 15) = 0 Then
If Cells(x, 10) >= Application.WorksheetFunction.Max(Range(Cells(x, 10).Offset(Cells(x, 11), 0), Cells(x, 10))) Then
Cells(y, 7) = Cells(x, 7) + 1 'when prev A?=0 and prev U is max
End If
End If
ElseIf Cells(x, 18) = 0 And Cells(x, 19) = 0 Then
If Cells(x, 15) = 0 Then
If Cells(x, 10) < Application.WorksheetFunction.Max(Range(Cells(x, 10).Offset(Cells(x, 11), 0), Cells(x, 10))) Then
Cells(y, 7) = Cells(x, 7) 'when prev A?=0 and prev U is max
End If
End If
Else: Cells(y, 7) = "Error"
End If
End Sub

Viewing all articles
Browse latest Browse all 21842

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>