G
Guest
What I'm trying to do is to force a zero into cell c13 in a particular
worksheet.
I have two macro - the first is always running in the background - and the
second is called by the first. It doesn't seem to matter where I try to
force the zero into cell c13 it forces the macro into the loop.
Any help would be appreciated.
The following macro is always running
Sub Worksheet_Change(ByVal Target As Range)
'If Target.Address = Range("product").Address Then
If Range("product").Value = "" Then
shtInput.[button 17].Visible = False
Exit Sub
End If
'End If
If Range("product").Value = "Capital_Bonus_2" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
shtInput.Protect
End If
If Range("product").Value = "Expanding_Horizon_5" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
shtInput.Protect
End If
If Range("product").Value = "Expanding_Horizon_7" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
shtInput.Protect
End If
If Range("product").Value = "GPA_5Yr" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "GPA_9Yr" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "Maximum_Solutions_II" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "GPA_Seminole_County" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "MY_Guaranteed_Solution_II" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = False
Range("SolvPrem").Select
Selection.Locked = True
' shtInput.Range("c13") = 0
If Range("GPeriod").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
Module1.check_error
End Sub
The following macro is check_error
Sub check_error()
Dim sht As Worksheet
shtCB2D.Visible = False
shtCB2V.Visible = False
shtMAX2D.Visible = False
shtMAX2V.Visible = False
shtEH5D.Visible = False
shtEH5V.Visible = False
shtEH7D.Visible = False
shtEH7V.Visible = False
shtGPA5D.Visible = False
shtGPAV.Visible = False
shtGPA9D.Visible = False
shtGPAV.Visible = False
shtGPASC.Visible = False
shtGPAV.Visible = False
shtMYGSD.Visible = False
shtMYGSV.Visible = False
shtAgent.Visible = False
If Range("product").Value = "MY_Guaranteed_Solution_II" Then
' shtInput.Range("c13") = 0
End If
For Each sht In Worksheets
' sht.Visible = True
Next
If shtInpInfo.Range("valid").Value <> 0 Then
shtInput.[button 17].Visible = False
Beep
End If
If shtInpInfo.Range("valid").Value = 0 Then
shtInput.[button 17].Visible = True
shtInput.[button 248].Visible = True
Select Case Range("product").Value
Case Is = "Capital_Bonus_2"
shtCB2D.Visible = True
shtCB2V.Visible = True
Case Is = "Maximum_Solutions_II"
shtMAX2D.Visible = True
shtMAX2V.Visible = True
Case Is = "Expanding_Horizon_5"
shtEH5D.Visible = True
shtEH5V.Visible = True
Case Is = "Expanding_Horizon_7"
shtEH7D.Visible = True
shtEH7V.Visible = True
Case Is = "GPA_5Yr"
shtGPA5D.Visible = True
shtGPAV.Visible = True
Case Is = "GPA_9Yr"
shtGPA9D.Visible = True
shtGPAV.Visible = True
Case Is = "GPA_Seminole_County"
shtGPASC.Visible = True
shtGPAV.Visible = True
Case Is = "MY_Guaranteed_Solution_II"
shtMYGSD.Visible = True
shtMYGSV.Visible = True
shtInput.[button 248].Visible = False
Case Else
MsgBox "Not a valid plan"
End Select
End If
End Sub
worksheet.
I have two macro - the first is always running in the background - and the
second is called by the first. It doesn't seem to matter where I try to
force the zero into cell c13 it forces the macro into the loop.
Any help would be appreciated.
The following macro is always running
Sub Worksheet_Change(ByVal Target As Range)
'If Target.Address = Range("product").Address Then
If Range("product").Value = "" Then
shtInput.[button 17].Visible = False
Exit Sub
End If
'End If
If Range("product").Value = "Capital_Bonus_2" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
shtInput.Protect
End If
If Range("product").Value = "Expanding_Horizon_5" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
shtInput.Protect
End If
If Range("product").Value = "Expanding_Horizon_7" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
shtInput.Protect
End If
If Range("product").Value = "GPA_5Yr" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "GPA_9Yr" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "Maximum_Solutions_II" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "GPA_Seminole_County" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = False
Range("GPeriod").Select
Selection.Locked = True
Range("SolvPrem").Select
Selection.Locked = False
If Range("RiskC").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
If Range("product").Value = "MY_Guaranteed_Solution_II" Then
shtInput.Unprotect
Range("RiskC").Select
Selection.Locked = True
Range("GPeriod").Select
Selection.Locked = False
Range("SolvPrem").Select
Selection.Locked = True
' shtInput.Range("c13") = 0
If Range("GPeriod").Value = "" Then
Exit Sub
End If
shtInput.Protect
End If
Module1.check_error
End Sub
The following macro is check_error
Sub check_error()
Dim sht As Worksheet
shtCB2D.Visible = False
shtCB2V.Visible = False
shtMAX2D.Visible = False
shtMAX2V.Visible = False
shtEH5D.Visible = False
shtEH5V.Visible = False
shtEH7D.Visible = False
shtEH7V.Visible = False
shtGPA5D.Visible = False
shtGPAV.Visible = False
shtGPA9D.Visible = False
shtGPAV.Visible = False
shtGPASC.Visible = False
shtGPAV.Visible = False
shtMYGSD.Visible = False
shtMYGSV.Visible = False
shtAgent.Visible = False
If Range("product").Value = "MY_Guaranteed_Solution_II" Then
' shtInput.Range("c13") = 0
End If
For Each sht In Worksheets
' sht.Visible = True
Next
If shtInpInfo.Range("valid").Value <> 0 Then
shtInput.[button 17].Visible = False
Beep
End If
If shtInpInfo.Range("valid").Value = 0 Then
shtInput.[button 17].Visible = True
shtInput.[button 248].Visible = True
Select Case Range("product").Value
Case Is = "Capital_Bonus_2"
shtCB2D.Visible = True
shtCB2V.Visible = True
Case Is = "Maximum_Solutions_II"
shtMAX2D.Visible = True
shtMAX2V.Visible = True
Case Is = "Expanding_Horizon_5"
shtEH5D.Visible = True
shtEH5V.Visible = True
Case Is = "Expanding_Horizon_7"
shtEH7D.Visible = True
shtEH7V.Visible = True
Case Is = "GPA_5Yr"
shtGPA5D.Visible = True
shtGPAV.Visible = True
Case Is = "GPA_9Yr"
shtGPA9D.Visible = True
shtGPAV.Visible = True
Case Is = "GPA_Seminole_County"
shtGPASC.Visible = True
shtGPAV.Visible = True
Case Is = "MY_Guaranteed_Solution_II"
shtMYGSD.Visible = True
shtMYGSV.Visible = True
shtInput.[button 248].Visible = False
Case Else
MsgBox "Not a valid plan"
End Select
End If
End Sub