disabling Run time error 13

rifleforger

New Member
Joined
Aug 1, 2010
Messages
6
Hi guys I always get run time error 13 whenever I want to add a row in my spreadsheet.

This code is to determine duplicate entries. SO whenever i want to insert a row the run time error 13 occurs
Private Sub Worksheet_Change(ByVal Target As Range)
If (Target.Column <> 5) And (Target.Column <> 10) And (Target.Column <> 1) And (Target.Column <> 2) Then Exit Sub

If WorksheetFunction.CountIf(Columns(5), Target.Value) > 1 Then
MsgBox "The serial number you have entered is already existing", vbExclamation
Target.Clear
ElseIf WorksheetFunction.CountIf(Columns(10), Target.Value) > 1 Then
MsgBox "The Device Name you have entered is already existing", vbExclamation
Target.Clear
ElseIf WorksheetFunction.CountIf(Columns(2), Target.Value) > 1 Then
MsgBox "The Device Asset you have entered is already existing", vbExclamation
Target.Clear
ElseIf WorksheetFunction.CountIf(Columns(1), Target.Value) > 1 Then
MsgBox "The System Asset you have entered is already existing", vbExclamation
Target.Clear
End If
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,452
Add something like this at the top of the macro...
Code:
If Target.Count > 1 Then Exit Sub
 

Forum statistics

Threads
1,176,718
Messages
5,904,609
Members
435,101
Latest member
oldmaninla

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