Inserting row stops macro

i8ig

Board Regular
Joined
Jul 17, 2007
Messages
122
I am running a spread sheet with a macro that auto populates multiple cells based on information input into certain cells. As more information is added, I add additional rowss. Each time I insert an additional row, my macro stops and I receive the message 'Runtime error 13' Type mismatch. and am given the option to 'End' or Debug' Is there a way to stop this error?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

i8ig

Board Regular
Joined
Jul 17, 2007
Messages
122
Code:
 Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
    If Target.Value = "Med" Then
        Rows(Target.Row).Interior.ColorIndex = 4
        Cells(Target.Row, 10) = "=IF(RC[3]="""","""",RC[3]-3)"
    Else
        If Target.Value = "Tasc" Then
            Rows(Target.Row).Interior.ColorIndex = 6
            Cells(Target.Row, 10) = "=IF(RC[1]="""","""",RC[1]-2)"
        Else
            If Target.Value = "Nbar" Then
                Rows(Target.Row).Interior.ColorIndex = x1ColorIndexNone
                Cells(Target.Row, 23) = "=IF(RC[-1]="""","""",RC[-1]+7)"
                Cells(Target.Row, 22) = "=IF(RC[-1]="""","""",RC[-1]+7)"
                Cells(Target.Row, 21) = "=IF(RC[-8]="""","""",RC[-8]+14)"
                Cells(Target.Row, 12) = "=IF(RC[1]="""","""",RC[1]-5)"
                Cells(Target.Row, 11) = "=IF(RC[1]="""","""",RC[1]-2)"
                Cells(Target.Row, 10) = "=IF(RC[1]="""","""",RC[1]-7)"
            Else
                Rows(Target.Row).Interior.ColorIndex = xlColorIndexNone
            End If
        End If
    End If
End If
End Sub

Also is there a way to protect the sheet and allow user to input information other than adding text to the macro to allow for unprotecting and then reprotecting?

any assistance is greatly appreciated
 

Forum statistics

Threads
1,181,730
Messages
5,931,703
Members
436,799
Latest member
BasOo

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
Top