D
DA@PD
I'm trying to create a really long =if command in Excel VBA editor but I keep
getting multiple errors, the latest is a "End if with no block If" error.
But I know I'm setting up the character values incorrectly also! Please
Help!!!
Sub Usage()
Dim Usage As Double
Dim J As Double
Dim K As Double
Dim L As Double
Dim M As Double
Dim N As Double
Dim O As Double
Dim P As Double
Dim Q As Double
Dim R As Double
Dim S As Double
Dim T As Double
Dim U As Double
Dim W As Double
K = Cell.K2
L = Cell.L2
M = Cell.M2
N = Cell.N2
O = Cell.O2
P = Cell.P2
Q = Cell.Q2
R = Cell.R2
S = Cell.S2
T = Cell.T2
U = Cell.U2
W = Cell.W2
Usage = (K + M + O + Q + S + U) / 6
If Usage > 20 Then Cell.AA2 = (W / 15) Else:
If (J / K) > (L / M) And (J / K) > (N / O) And (J / K) > (P / Q) And (J / K)
End If
End If
End If
End If
End If
End If
Selection.AutoFill Destination:=Range("AA2:AA3943"), Type:=xlFillDefault
Range("AA2:AA3943").Select
End Sub
getting multiple errors, the latest is a "End if with no block If" error.
But I know I'm setting up the character values incorrectly also! Please
Help!!!
Sub Usage()
Dim Usage As Double
Dim J As Double
Dim K As Double
Dim L As Double
Dim M As Double
Dim N As Double
Dim O As Double
Dim P As Double
Dim Q As Double
Dim R As Double
Dim S As Double
Dim T As Double
Dim U As Double
Dim W As Double
K = Cell.K2
L = Cell.L2
M = Cell.M2
N = Cell.N2
O = Cell.O2
P = Cell.P2
Q = Cell.Q2
R = Cell.R2
S = Cell.S2
T = Cell.T2
U = Cell.U2
W = Cell.W2
Usage = (K + M + O + Q + S + U) / 6
If Usage > 20 Then Cell.AA2 = (W / 15) Else:
If (J / K) > (L / M) And (J / K) > (N / O) And (J / K) > (P / Q) And (J / K)
If (L / M) > (J / K) And (L / M) > (N / O) And (L / M) > (P / Q) And (L / M)(R / S) And (J / K) > (T / U) Then Cell.AA2 = (J / K) Else:
If (N / O) > (L / M) And (N / O) > (J / K) And (N / O) > (P / Q) And (N / O)(R / S) And (L / M) > (T / U) Then Cell.AA2 = (L / M) Else:
If (P / Q) > (L / M) And (P / Q) > (N / O) And (P / Q) > (J / K) And (P / Q)(R / S) And (N / O) > (T / U) Then Cell.AA2 = (N / O) Else:
If (R / S) > (L / M) And (R / S) > (N / O) And (R / S) > (P / Q) And (R / S)(R / S) And (P / Q) > (T / U) Then Cell.AA2 = (J / K) Else:
If (T / U) > (L / M) And (T / U) > (N / O) And (T / U) > (P / Q) And (T / U)(J / K) And (R / S) > (T / U) Then Cell.AA2 = (R / S) Else:
End If(R / S) And (T / U) > (J / K) Then Cell.AA2 = (T / U)
End If
End If
End If
End If
End If
End If
Selection.AutoFill Destination:=Range("AA2:AA3943"), Type:=xlFillDefault
Range("AA2:AA3943").Select
End Sub