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 to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

AlphaFrog

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

Forum statistics

Threads
1,181,322
Messages
5,929,300
Members
436,660
Latest member
Mouseinalabyrinth

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