Run-time error "13": Type mismatch

richiesngh35

New Member
Joined
Mar 29, 2019
Messages
1
I have an excel template (Productivity Tracker), where we have to put specific request number based on various task. For e.g. for task MDC Account Creation, request number should start with "A" follow by seven digits(numbers) ex A9827366, total length 8. So, for each different unique task I have defined Starting Alphabet and number of digits in a different sheet. When an employee enter a request number in the request number field it than automatically match the input with the already defined details(Starting Alphabet and number of digits) which will reflect in D7 cell(Starting Alphabet match) as True/False/#N/A and E7 cell(length match) as True/False/#N/A. If the result is "false", it will through a msg "Incorrect Length of Request Number" or "Incorrect Request Number". As a result it won't be saved in the data base.
I want these two msg to to be ignored for few tasks for which I have not defined any (Starting Alphabet and Length) due to which it shows "#N/A" in D7 or E7 cell.
I just was this msg to not come when both the cell value says "#N/A".


Code:
If (Worksheets("Entry").Range("d7").Value = False) Then
MsgBox ("Incorrect Request Number"), vbCritical
Sheet1.Protect Password:="xepo101"
Exit Sub
End If


If (Worksheets("Entry").Range("e7").Value = False) Then
MsgBox ("Incorrect Length of Request Number"), vbCritical
Sheet1.Protect Password:="xepo101"
Exit Sub
End If
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
try this

Code:
    If IsError(Worksheets("Entry").Range("d7").Value) Then
        MsgBox ("Incorrect Request Number"), vbCritical
        sheet1.Protect Password:="xepo101"
        Exit Sub
    End If
    If (Worksheets("Entry").Range("d7").Value = False) Then
        MsgBox ("Incorrect Request Number"), vbCritical
        sheet1.Protect Password:="xepo101"
        Exit Sub
    End If
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,172
Members
449,071
Latest member
cdnMech

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