Please help with error message - "Code execution has been interrupted"

tomwhi

New Member
Joined
May 13, 2013
Messages
35
Hello all,

I have the below VBA within a worksheet. However, I am received this error message, "Code execution has been interrupted" almost at random. Sometimes it works, sometimes it doesnt. Any thought??

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Last edited by Tom White on 01/10/2014
'AIP
If Target.Address = "$C$30" Then
    If Target.Value = "No" Then
        Sheets("Corp Assign Dom Relo").Rows("38:39").EntireRow.Hidden = True
        Sheets("Corp Offer Letter Dom Relo").Rows("36:37").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Exempt").Rows("36:37").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Non Exempt").Rows("36:37").EntireRow.Hidden = True
        Sheets("Corp Promo - Exempt").Rows("36:37").EntireRow.Hidden = True
        Sheets("Corp Promo - Non Exempt").Rows("36:37").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Letter - Exempt").Rows("40:41").EntireRow.Hidden = True
        Sheets("Dom Rota Promo - Exempt").Rows("40:41").EntireRow.Hidden = True
        Sheets("Expat Resident Assignment").Rows("44:45").EntireRow.Hidden = True
        Sheets("Expat Resident Offer Letter").Rows("42:43").EntireRow.Hidden = True
        Sheets("Corp Repatriation - Dom Relo").Rows("38:39").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt").Rows("48:49").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("46:47").EntireRow.Hidden = True
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("50:51").EntireRow.Hidden = True
        Sheets("RDIS Expat Assignment").Rows("32:33").EntireRow.Hidden = True
        Sheets("RDIS Expat Offer Letter").Rows("34:35").EntireRow.Hidden = True
        Sheets("RDIS Int. Rotator Assign").Rows("57:58").EntireRow.Hidden = True
        Sheets("RDIS Int.Rot. Offer Letter").Rows("36:37").EntireRow.Hidden = True
        Sheets("RDIS Expat Assign same location").Rows("50:51").EntireRow.Hidden = True
    Else
        Sheets("Corp Assign Dom Relo").Rows("38:39").EntireRow.Hidden = False
        Sheets("Corp Offer Letter Dom Relo").Rows("36:37").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Exempt").Rows("36:37").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Non Exempt").Rows("36:37").EntireRow.Hidden = False
        Sheets("Corp Promo - Exempt").Rows("36:37").EntireRow.Hidden = False
        Sheets("Corp Promo - Non Exempt").Rows("36:37").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Letter - Exempt").Rows("40:41").EntireRow.Hidden = False
        Sheets("Dom Rota Promo - Exempt").Rows("40:41").EntireRow.Hidden = False
        Sheets("Expat Resident Assignment").Rows("44:45").EntireRow.Hidden = False
        Sheets("Expat Resident Offer Letter").Rows("42:43").EntireRow.Hidden = False
        Sheets("Corp Repatriation - Dom Relo").Rows("38:39").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt").Rows("48:49").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("46:47").EntireRow.Hidden = False
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("50:51").EntireRow.Hidden = False
        Sheets("RDIS Expat Assignment").Rows("32:33").EntireRow.Hidden = False
        Sheets("RDIS Expat Offer Letter").Rows("34:35").EntireRow.Hidden = False
        Sheets("RDIS Int. Rotator Assign").Rows("57:58").EntireRow.Hidden = False
        Sheets("RDIS Int.Rot. Offer Letter").Rows("36:37").EntireRow.Hidden = False
        Sheets("RDIS Expat Assign same location").Rows("50:51").EntireRow.Hidden = False
    End If
    End If
    
'LTIP
If Target.Address = "$C$31" Then
    If Target.Value = "No" Then
        Sheets("Corp Assign Dom Relo").Rows("40:41").EntireRow.Hidden = True
        Sheets("Corp Offer Letter Dom Relo").Rows("38:39").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Exempt").Rows("38:39").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Non Exempt").Rows("38:39").EntireRow.Hidden = True
        Sheets("Corp Promo - Exempt").Rows("38:39").EntireRow.Hidden = True
        Sheets("Expat Resident Assignment").Rows("46:47").EntireRow.Hidden = True
        Sheets("Expat Resident Offer Letter").Rows("44:45").EntireRow.Hidden = True
        Sheets("Corp Repatriation - Dom Relo").Rows("40:41").EntireRow.Hidden = True
        Sheets("RDIS Expat Assignment").Rows("34:35").EntireRow.Hidden = True
        Sheets("RDIS Expat Offer Letter").Rows("36:37").EntireRow.Hidden = True
        Sheets("RDIS Expat Assign same location").Rows("52:53").EntireRow.Hidden = True
    Else
        Sheets("Corp Assign Dom Relo").Rows("40:41").EntireRow.Hidden = False
        Sheets("Corp Offer Letter Dom Relo").Rows("38:39").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Exempt").Rows("38:39").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Non Exempt").Rows("38:39").EntireRow.Hidden = False
        Sheets("Corp Promo - Exempt").Rows("38:39").EntireRow.Hidden = False
        Sheets("Expat Resident Assignment").Rows("46:47").EntireRow.Hidden = False
        Sheets("Expat Resident Offer Letter").Rows("44:45").EntireRow.Hidden = False
        Sheets("Corp Repatriation - Dom Relo").Rows("40:41").EntireRow.Hidden = False
        Sheets("RDIS Expat Assignment").Rows("34:35").EntireRow.Hidden = False
        Sheets("RDIS Expat Offer Letter").Rows("36:37").EntireRow.Hidden = False
        Sheets("RDIS Expat Assign same location").Rows("52:53").EntireRow.Hidden = False
        End If
        End If
        
'Primary Sign On
If Target.Address = "$C$32" Then
    If Target.Value = "No" Then
        Sheets("Corp Offer Letter Dom Relo").Rows("40:41").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Exempt").Rows("40:41").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Non Exempt").Rows("40:41").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Letter - Exempt").Rows("42:43").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("40:41").EntireRow.Hidden = True
        Sheets("Expat Resident Offer Letter").Rows("46:47").EntireRow.Hidden = True
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("46:47").EntireRow.Hidden = True
        Sheets("RDIS Expat Offer Letter").Rows("38:39").EntireRow.Hidden = True
        Sheets("RDIS Int.Rot. Offer Letter").Rows("40:41").EntireRow.Hidden = True
    Else
        Sheets("Corp Offer Letter Dom Relo").Rows("40:41").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Exempt").Rows("40:41").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Non Exempt").Rows("40:41").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Letter - Exempt").Rows("42:43").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("40:41").EntireRow.Hidden = False
        Sheets("Expat Resident Offer Letter").Rows("46:47").EntireRow.Hidden = False
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("46:47").EntireRow.Hidden = False
        Sheets("RDIS Expat Offer Letter").Rows("38:39").EntireRow.Hidden = False
        Sheets("RDIS Int.Rot. Offer Letter").Rows("40:41").EntireRow.Hidden = False
    End If
    End If
            
'Exceptional Sign On
If Target.Address = "$C$33" Then
    If Target.Value = "No" Then
        Sheets("Corp Offer Letter Dom Relo").Rows("42:43").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Exempt").Rows("42:43").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Non Exempt").Rows("42:43").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Letter - Exempt").Rows("44:45").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("42:43").EntireRow.Hidden = True
        Sheets("Expat Resident Offer Letter").Rows("48:49").EntireRow.Hidden = True
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("48:49").EntireRow.Hidden = True
        Sheets("RDIS Expat Offer Letter").Rows("40:42").EntireRow.Hidden = True
        Sheets("RDIS Int.Rot. Offer Letter").Rows("42:43").EntireRow.Hidden = True
    Else
        Sheets("Corp Offer Letter Dom Relo").Rows("42:43").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Exempt").Rows("42:43").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Non Exempt").Rows("42:43").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Letter - Exempt").Rows("44:45").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("42:43").EntireRow.Hidden = False
        Sheets("Expat Resident Offer Letter").Rows("48:49").EntireRow.Hidden = False
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("48:49").EntireRow.Hidden = False
        Sheets("RDIS Expat Offer Letter").Rows("40:42").EntireRow.Hidden = False
        Sheets("RDIS Int.Rot. Offer Letter").Rows("42:43").EntireRow.Hidden = False
    End If
    End If
            
'Initial Equity
If Target.Address = "$C$34" Then
    If Target.Value = "No" Then
        Sheets("Corp Assign Dom Relo").Rows("42:44").EntireRow.Hidden = True
        Sheets("Corp Offer Letter Dom Relo").Rows("45:47").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Exempt").Rows("45:47").EntireRow.Hidden = True
        Sheets("Corp Offer Letter - Non Exempt").Rows("45:47").EntireRow.Hidden = True
        Sheets("Corp Promo - Exempt").Rows("40:42").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Letter - Exempt").Rows("48:50").EntireRow.Hidden = True
        Sheets("Expat Resident Assignment").Rows("48:50").EntireRow.Hidden = True
        Sheets("Expat Resident Offer Letter").Rows("50:52").EntireRow.Hidden = True
        Sheets("Corp Repatriation - Dom Relo").Rows("42:44").EntireRow.Hidden = True
        Sheets("RDIS Expat Assignment").Rows("36:38").EntireRow.Hidden = True
        Sheets("RDIS Expat Offer Letter").Rows("42:44").EntireRow.Hidden = True
        Sheets("RDIS Expat Assign same location").Rows("54:56").EntireRow.Hidden = True
    Else
        Sheets("Corp Assign Dom Relo").Rows("42:44").EntireRow.Hidden = False
        Sheets("Corp Offer Letter Dom Relo").Rows("45:47").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Exempt").Rows("45:47").EntireRow.Hidden = False
        Sheets("Corp Offer Letter - Non Exempt").Rows("45:47").EntireRow.Hidden = False
        Sheets("Corp Promo - Exempt").Rows("40:42").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Letter - Exempt").Rows("48:50").EntireRow.Hidden = False
        Sheets("Expat Resident Assignment").Rows("48:50").EntireRow.Hidden = False
        Sheets("Expat Resident Offer Letter").Rows("50:52").EntireRow.Hidden = False
        Sheets("Corp Repatriation - Dom Relo").Rows("42:44").EntireRow.Hidden = False
        Sheets("RDIS Expat Assignment").Rows("36:38").EntireRow.Hidden = False
        Sheets("RDIS Expat Offer Letter").Rows("42:44").EntireRow.Hidden = False
        Sheets("RDIS Expat Assign same location").Rows("54:56").EntireRow.Hidden = False
    End If
    End If
            
'Transfer
If Target.Address = "$I$21" Then
    If Target.Value = "No" Then
        Sheets("Corp Assign Dom Relo").Rows("57:62").EntireRow.Hidden = True
        Sheets("Expat Resident Assignment").Rows("55:60").EntireRow.Hidden = True
        Sheets("Corp Repatriation - Dom Relo").Rows("56:61").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt").Rows("54:59").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt").Rows("52:57").EntireRow.Hidden = True
        Sheets("RDIS Expat Assignment").Rows("43:48").EntireRow.Hidden = True
    Else
        Sheets("Corp Assign Dom Relo").Rows("57:62").EntireRow.Hidden = False
        Sheets("Expat Resident Assignment").Rows("55:60").EntireRow.Hidden = False
        Sheets("Corp Repatriation - Dom Relo").Rows("56:61").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt").Rows("54:59").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt").Rows("52:57").EntireRow.Hidden = False
        Sheets("RDIS Expat Assignment").Rows("43:48").EntireRow.Hidden = False
    End If
    End If
    
'Probationary Period
If Target.Address = "$C$29" Then
    If Target.Value = "No" Then
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("53:55").EntireRow.Hidden = True
    Else
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("53:55").EntireRow.Hidden = False
    End If
    End If
    
'Retention Bonus
If Target.Address = "$C$37" Then
    If Target.Value = "No" Then
        Sheets("Dom Rota Offer Letter - Exempt").Rows("46:47").EntireRow.Hidden = True
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("44:45").EntireRow.Hidden = True
        Sheets("Dom Rota Promo - Exempt").Rows("42:43").EntireRow.Hidden = True
        Sheets("Dom Rota Promo - Non Exempt").Rows("42:43").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt").Rows("50:51").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("48:49").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt").Rows("48:49").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt Short").Rows("46:47").EntireRow.Hidden = True
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("52:53").EntireRow.Hidden = True
        Sheets("RDIS Int. Rotator Assign").Rows("59:60").EntireRow.Hidden = True
        Sheets("RDIS Int.Rot. Offer Letter").Rows("38:39").EntireRow.Hidden = True
    Else
        Sheets("Dom Rota Offer Letter - Exempt").Rows("46:47").EntireRow.Hidden = False
        Sheets("Dom Rota Offer Let - Non Exempt").Rows("44:45").EntireRow.Hidden = False
        Sheets("Dom Rota Promo - Exempt").Rows("42:43").EntireRow.Hidden = False
        Sheets("Dom Rota Promo - Non Exempt").Rows("42:43").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt").Rows("50:51").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("48:49").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt").Rows("48:49").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt Short").Rows("46:47").EntireRow.Hidden = False
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("52:53").EntireRow.Hidden = False
        Sheets("RDIS Int. Rotator Assign").Rows("59:60").EntireRow.Hidden = False
        Sheets("RDIS Int.Rot. Offer Letter").Rows("38:39").EntireRow.Hidden = False
    End If
    End If
    
'Foreign Service Premium
If Target.Address = "$C$38" Then
    If Target.Value = "No" Then
        Sheets("Expat Resident Assignment").Rows("40:43").EntireRow.Hidden = True
        Sheets("Expat Resident Offer Letter").Rows("38:41").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt").Rows("38:41").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("36:39").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt").Rows("38:41").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt Short").Rows("36:39").EntireRow.Hidden = True
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("44:45").EntireRow.Hidden = True
        Sheets("RDIS Expat Assignment").Rows("132:135").EntireRow.Hidden = True
        Sheets("RDIS Expat Offer Letter").Rows("135:138").EntireRow.Hidden = True
        Sheets("RDIS Int. Rotator Assign").Rows("49:52").EntireRow.Hidden = True
        Sheets("RDIS Int.Rot. Offer Letter").Rows("129:132").EntireRow.Hidden = True
        Sheets("RDIS Expat Assign same location").Rows("46:49").EntireRow.Hidden = True
    Else
        Sheets("Expat Resident Assignment").Rows("40:43").EntireRow.Hidden = False
        Sheets("Expat Resident Offer Letter").Rows("38:41").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt").Rows("38:41").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("36:39").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt").Rows("38:41").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt Short").Rows("36:39").EntireRow.Hidden = False
        Sheets("Intl.Rot. Offer letter - Exempt").Rows("44:45").EntireRow.Hidden = False
        Sheets("RDIS Expat Assignment").Rows("132:135").EntireRow.Hidden = False
        Sheets("RDIS Expat Offer Letter").Rows("135:138").EntireRow.Hidden = False
        Sheets("RDIS Int. Rotator Assign").Rows("49:52").EntireRow.Hidden = False
        Sheets("RDIS Int.Rot. Offer Letter").Rows("129:132").EntireRow.Hidden = False
        Sheets("RDIS Expat Assign same location").Rows("46:49").EntireRow.Hidden = False
    End If
    End If
    
'Per Diem
If Target.Address = "$C$39" Then
    If Target.Value = "No" Then
        Sheets("Intl. Rot. Assign-Exempt").Rows("44:45").EntireRow.Hidden = True
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("42:43").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt").Rows("44:45").EntireRow.Hidden = True
        Sheets("Intl.Rot.Assign-NonExempt Short").Rows("42:43").EntireRow.Hidden = True
        Sheets("RDIS Int. Rotator Assign").Rows("55:56").EntireRow.Hidden = True
        Sheets("RDIS Int.Rot. Offer Letter").Rows("133:134").EntireRow.Hidden = True
    Else
        Sheets("Intl. Rot. Assign-Exempt").Rows("44:45").EntireRow.Hidden = False
        Sheets("Intl. Rot. Assign-Exempt-Short").Rows("42:43").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt").Rows("44:45").EntireRow.Hidden = False
        Sheets("Intl.Rot.Assign-NonExempt Short").Rows("42:43").EntireRow.Hidden = False
        Sheets("RDIS Int. Rotator Assign").Rows("55:56").EntireRow.Hidden = False
        Sheets("RDIS Int.Rot. Offer Letter").Rows("133:134").EntireRow.Hidden = False
    End If
    End If
    
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Consider alternatively re-booting the computer. That has always worked for me. The solution in the posted link removes the ability to CTRL-BREAK the code.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top