gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I have code that I want to run only if several cells have data in it.
E7
E9
E11
E13
E15
M7
M9
M11
M13
M15
I don't want it to do an If for each individual cell (If, then, If, Then....)
I want to run the code and check these. If any are blank, stop the code and open UserForm5
Thanks
E7
E9
E11
E13
E15
M7
M9
M11
M13
M15
I don't want it to do an If for each individual cell (If, then, If, Then....)
I want to run the code and check these. If any are blank, stop the code and open UserForm5
Code:
Private Sub CommandButton1_Click()
Calculate
Dim CurRow As Integer
Dim NumMonths As Integer
Dim Amount As Double
Dim Dcurv As Integer
'Changed
Dcurv = Cells(71, 2).Value
NumMonths = Cells(75, 2).Value
Amount = Cells(72, 2).Value
Range(Cells(77, 1), Cells(570, 2)).ClearContents
CurRow = 76
a = 1 / NumMonths
W = Amount
Min = 1
'All other curves-------------
BOG = 0.01 * Dcurv
S = BOG
For i = 1 To 40
S = Sqr(BOG / (3 - (2 * S)))
Next
p = 0
CL = 0
For K = 1 To NumMonths
Cells(K + CurRow, 1).Value = K
p = p + a
X = (1 - 2 * S) * p * (((-4 * p + 8) * p - 3) * p) + 2 * S * p
C = X * X * (3 - 2 * X)
XX = Min
Cells(K + CurRow, 2).Value = ((C - CL) * XX * W)
CL = C
If K = 1 Then
Cells(K + CurRow, 1).Formula = "=EOMONTH(B73,0)"
Cells(K + CurRow, 1).NumberFormat = "mmm-yy"
Else
Cells(K + CurRow, 1).FormulaR1C1 = "=EOMONTH(R[-1]C,1)"
Cells(K + CurRow, 11).NumberFormat = "mmm-yy"
End If
Next
Range("S1").Activate
Calculate
End Sub
Thanks