# Inserting row stops macro

#### i8ig

##### Board Regular
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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
i8ig,

Have a great day,
Stan

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

Replies
2
Views
90
Replies
4
Views
519
Replies
2
Views
755
Replies
0
Views
301
Replies
8
Views
539

1,219,792
Messages
6,150,291
Members
450,949
Latest member
faizanmalik10

### 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.

### Which adblocker are you using?

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

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