Run-time error '13': Type mismatch

pells

Active Member
Joined
Dec 5, 2008
Messages
361
I am trying to the the following code but I am getting this error, run-time error '13': Type mismatch:

If ActiveSheet.Range("G11:G88") > 0 Then
MsgBox "No code entered!", vbExclamation, "Error"
Exit Sub
End If

Am I using the correct syntax and does anyone know how to resolve my error so that it works?

Many thanks.
 
Take the last bit of code I suggested and modify it to:
Rich (BB code):
If Application.CountBlank(Range("H11:H88")) > 0 OR _
   Application.Max(Range("G11:G88")) > 0 Then
MsgBox ("No code entered!", vbExclamation, "Error")
        Exit Sub
End If
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Take the last bit of code I suggested and modify it to:
Rich (BB code):
If Application.CountBlank(Range("H11:H88")) > 0 OR _
   Application.Max(Range("G11:G88")) > 0 Then
MsgBox ("No code entered!", vbExclamation, "Error")
        Exit Sub
End If
Many thanks for this. I have tried it and am getting the following error:

Compile error:

Expected: =

Any ideas?
 
Upvote 0
I included some brackets that weren't needed:
Code:
If Application.CountBlank(Range("H11:H88")) > 0 Or _
   Application.Max(Range("G11:G88")) > 0 Then
    MsgBox "No code entered!", vbExclamation, "Error"
    Exit Sub
End If
 
Upvote 0
I included some brackets that weren't needed:
Code:
If Application.CountBlank(Range("H11:H88")) > 0 Or _
   Application.Max(Range("G11:G88")) > 0 Then
    MsgBox "No code entered!", vbExclamation, "Error"
    Exit Sub
End If
I have tried this but it doesnt work.

If I enter something into cell H11, I still get the error message "No code entered!" although it shouldnt appear. If I remove the cell contents, I get the error as you would expect.

Any ideas?
 
Upvote 0
Many thanks for all your replies, they have been most helpful.

The following code works perfectly for one cell reference but not for a range of cells. I have tried various combinations of the code that you have all supplied, but I still cant seem to get it to work and was wondering whether any of you super guru's will be able to assist me again:

The code that works perfectly for one cell is:

If ActiveSheet.Range("G89") > 0 And IsEmpty(ActiveSheet.Range("H11")) Then
MsgBox "No code entered!", vbExclamation, "Error"
Exit Sub
End If


I need my code to be changed (range highlighted in red) to the following so that it works as it should:

If ActiveSheet.Range("G89") > 0 And IsEmpty(ActiveSheet.Range("H11:H88")) Then
MsgBox "No code entered!", vbExclamation, "Error"
Exit Sub
End If


Once again many thanks and hope that you will be able to help me once more?
 
Upvote 0

Forum statistics

Threads
1,225,155
Messages
6,183,215
Members
453,151
Latest member
Lizamaison

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