Run time error '13' - type mismatch

airportzoo

New Member
Joined
Jun 24, 2011
Messages
14
Hello

I have the run time error '13' type mismatch problem on the line that I have bolded. I think I understand why the problem occurs (something to do with the value in the cell being a number, not a bit of text), I just don't know how to solve it.

What is really annoying about it all is that we don't get the error in Excel 2007 until the file is sent in an email, used in Excel 2010, and when it's sent back to be used in Excel 2007 again, the problem arises. I have to then revert to the backed up original '07 file before it was sent in the email.

Basically, this spreadsheet is used to send text messages to numbers in certain columns. If the relevant cell is empty, this error handler kicks in to collect a number from the user.

Code:
Dim PhNum As String
......
errhandler:
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With

    With ActiveSheet.Buttons(MyButton)
    [B]PhNum = Application.InputBox("Phone number for employee missing. Text not sent." & vbNewLine & "Check name and employee number." & vbNewLine & vbNewLine & "If you know the number, type it into the box below," & vbNewLine & "WITHOUT ANY LEADING ZEROS AND WITH THE COUNTRY CODE I.E. 447906684330", Title:="Employee Contact", Default:=IIf(Range(.TopLeftCell, .BottomRightCell).Offset(, -2) >=[/B][B] "0", (Range(.TopLeftCell, .BottomRightCell).Offset(, -2).Value), "Enter the number here"), Type:=1)[/B]
    If PhNum = vbNullString Then
    ElseIf PhNum = "false" Then
    Exit Sub

Is there a solution with the whole Excel 2007/2010 problem?

Any help you could give would be amazing.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,824
Messages
6,127,109
Members
449,359
Latest member
michael2

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