Private Sub Worksheet_Change(ByVal Target As Range) ERROR

rbkinkead

New Member
Joined
May 29, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a worksheet that requires a checkmark or N/A in many cells.
I set the font as Wingdins2, and have each of these cells with data validation (=Check,N/A)
I have the following in the worksheet:

Private Sub Worksheet_Change(ByVal Target As Range)
'Sets Checkmark or N/A (Wingdings2 font)

If Intersect(Target, Range("A14:A16,a22,c23,a24:a28,a33:a39,a45,a47:a49,y14:y37,y42,aa43:aa46,y47:y48,y53:y56,y61")) Is Nothing Then Exit Sub

If Target.Value = "Check" Then
Target.Value = "P"
ElseIf Target.Value = "N/A" Then
Target.Value = "S"
End If
End Sub

If Check is selected from dropdown it returns the value "P" (Wingdings2 Checkmark)
If N/A is selected from dropdown it returns the value "S" (Wingdings2
1653849336524.png
)

The code works well, but, if you attempt to delete more than one target cell contents, it throws and error, (Run-time error '13': Type Mismatch) and debug highlights the first If Target statement.
Any help with this will be greatly appreciated.
 

Attachments

  • RTE.png
    RTE.png
    9.8 KB · Views: 8
  • Debug.png
    Debug.png
    17.4 KB · Views: 8

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Add this as the 1st line of code within the sub
VBA Code:
If Target.CountLarge > 1 Then Exit Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

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