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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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