Error 13 run-time - mismatch - message

handric

New Member
Joined
Feb 17, 2023
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hi,

After clearing content of cells i got this message : Run-time error 13 ; Type mismatch

The code is this :

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target

'declare condition to exit sub: single cell + value>0
If .Count > 1 Or Not IsNumeric(Target) Or .Value <= 0 Then Exit Sub

' If do not want trigger change from row n (i.e, from row 10).
'If .Count > 1 Or Not IsNumeric(Target) Or .Value <= 0 Or .Row > 10 Then Exit Sub

Select Case .Column
Case 7, 9 'column F or H
.Offset(0, 2).Select
Case 11 'column I
.Offset(1, -4).Select
Case Else
Exit Sub
End Select
End With

End Sub

The code is working fine. Only thing is when you clear cell content after taking measurement, I got this message.
I presume this is the problem of data type defined as something different.

Any suggestions please.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Change:
Code:
If .Count > 1 Or Not IsNumeric(Target) Or .Value <= 0 Or .Row > 10 Then Exit Sub
to:
Code:
If .Count > 1  Then Exit Sub
If Not IsNumeric(Target) Then Exit Sub
If .Value <= 0  Then Exit Sub
If .Row > 10 Then Exit Sub
 
Upvote 0
Change:
Code:
If .Count > 1 Or Not IsNumeric(Target) Or .Value <= 0 Or .Row > 10 Then Exit Sub
to:
Code:
If .Count > 1  Then Exit Sub
If Not IsNumeric(Target) Then Exit Sub
If .Value <= 0  Then Exit Sub
If .Row > 10 Then Exit Sub
Thank you. That solved the problem.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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