Here are all four option buttons. I have made changes since Dan-HalfAce-Urton helped me with it. (In other words, I take the blame for any of the dumb stuff). The real question is why the "If OptionButtonx" in each of the four macros?
Gene, "The Mortgage Man", Klein
Private Sub OptionButton1_Change()
'// This choice is no advance payments
Dim AdvanceStart As Integer
AdvanceStart = Application.CountIf(Range("bopaid"), 1) + _
Application.CountIf(Range("bopaid"), 100) + 2
If OptionButton1 Then
'// save old state for undo capability
'// oldbopaid was decleared as public in module 1
For i = 1 To 360 ' change this hard code later
oldbopaid(i) = Range("bopaid")(i)
Next i
'//
Range("principle_coupon") = 0
Range("numofpayments_coupon") = 0
Range("interestsaved_coupon") = 0
Range("bopaid")(AdvanceStart - 1) = 1
Range("ExcelBankName") = Me.Controls("TextBox1").Value
Range("ExcelAccountNumber") = Me.Controls("TextBox2").Value
Unload UserForm3
ActiveWorkbook.Save
End If
End Sub
Private Sub OptionButton2_Change()
Dim AdvanceStart As Integer
AdvanceStart = Application.CountIf(Range("bopaid"), 1) + _
Application.CountIf(Range("bopaid"), 100) + 2
If OptionButton2 Then
'// save old state for undo capability
'// oldbopaid was decleared as public in module 1
For i = 1 To 360 ' change this hard code later
oldbopaid(i) = Range("bopaid")(i)
Next i
'//
Range("principle_coupon") = Range("AdvanceRange")(AdvanceStart)
Range("numofpayments_coupon") = 1
Range("bopaid")(AdvanceStart - 1) = 1
Range("bopaid")(AdvanceStart) = 100
Call bohide
Range("isaved").Value = Evaluate("=sumproduct(interestrange,--(bopaid = 100))")
Range("interestsaved_coupon") = Range("isaved").Text
Range("ExcelBankName") = Me.Controls("TextBox1").Value
Range("ExcelAccountNumber") = Me.Controls("TextBox2").Value
Call bohide
Unload UserForm3
Call Print_Prepay_Coupon
ActiveWorkbook.Save
End If
End Sub
Private Sub OptionButton3_change()
Dim AdvanceStart As Integer
AdvanceStart = Application.CountIf(Range("bopaid"), 1) + _
Application.CountIf(Range("bopaid"), 100) + 2
If OptionButton3 Then
'// save old state for undo capability
'// oldbopaid was decleared as public in module 1
For i = 1 To 360 ' change this hard code later
oldbopaid(i) = Range("bopaid")(i)
Next i
'//
Range("principle_coupon") = Range("AdvanceRange")(AdvanceStart + 1)
Range("numofpayments_coupon") = 2
Range("bopaid")(AdvanceStart - 1) = 1
Range("bopaid")(AdvanceStart) = 100
Range("bopaid")(AdvanceStart + 1) = 100
Call bohide
Range("isaved").Value = Evaluate("=sumproduct(interestrange,--(bopaid = 100))")
Range("interestsaved_coupon") = Range("isaved").Text
Range("ExcelBankName") = Me.Controls("TextBox1").Value
Range("ExcelAccountNumber") = Me.Controls("TextBox2").Value
Call bohide
Unload UserForm3
Call Print_Prepay_Coupon
ActiveWorkbook.Save
End If
End Sub
Private Sub OptionButton4_change()
Dim AdvanceStart As Integer
AdvanceStart = Application.CountIf(Range("bopaid"), 1) + _
Application.CountIf(Range("bopaid"), 100) + 2
If OptionButton4 Then
'// save old state for undo capability
'// oldbopaid was decleared as public in module 1
For i = 1 To 360 ' change this hard code later
oldbopaid(i) = Range("bopaid")(i)
Next i
'//
Range("principle_coupon") = Range("AdvanceRange")(AdvanceStart + 2)
Range("numofpayments_coupon") = 3
Range("bopaid")(AdvanceStart - 1) = 1
Range("bopaid")(AdvanceStart) = 100
Range("bopaid")(AdvanceStart + 1) = 100
Range("bopaid")(AdvanceStart + 2) = 100
Call bohide
Range("isaved").Value = Evaluate("=sumproduct(interestrange,--(bopaid = 100))")
Range("interestsaved_coupon") = Range("isaved").Text
Range("ExcelBankName") = Me.Controls("TextBox1").Value
Range("ExcelAccountNumber") = Me.Controls("TextBox2").Value
Call bohide
Unload UserForm3
Call Print_Prepay_Coupon
ActiveWorkbook.Save
End If
End Sub