finding cause of type mismatch error. - solved

MO-KAN SHO

New Member
Joined
Apr 11, 2005
Messages
49
#1, I'm not experienced in VBA, so what code I do have is basically written by modifying code found on this forum. That's how I got this far.

#2, I can't find out why I'm getting a runtime error 13 'type mismatch' error when running this code. From what I'm deciphering from the how much of the code is running first the error must be due to one of the lines marked with asterisks. But I don't know how to fix it.

Code:
Sub auto_open()
poneeded = MsgBox("Do you need a Purchase Order Number?", vbYesNo)
    If poneeded = vbNo Then
        Exit Sub
    End If
    If poneeded = vbYes Then
        Application.ScreenUpdating = False
        Range("B65536").End(xlUp).Offset(1, 0).Select
        Application.ScreenUpdating = True
        
        Dim strVendor As String
        Dim strTech As String
        Dim strReason As String
        Dim strAssigner As String
        Dim po As String
        
        
        
        un = Environ("USERAME")
            Do Until strVendor <> ""
                strVendor = InputBox("Which Vendor?", "PO Information")
            Loop
            Do Until strTech <> ""
                strTech = InputBox("Who's requesting this PO?", "PO Information")
            Loop
            Do Until strReason <> ""
                strReason = InputBox("What customer or purpose is this PO for?", "PO Information")
            Loop
            ActiveCell.Offset(0, 0) = strVendor
            ActiveCell.Offset(0, 1) = strTech
            ActiveCell.Offset(0, 2) = strReason
'*******************************************************
            ActiveCell.Offset(0, 3) = Date
            ActiveCell.Offset(0, 4) = un
'*******************************************************
            ActiveCell.Offset(0, -1) = ActiveCell.Offset(-1, -1).Value + 1
            po = MsgBox("PO Number Assigned is: " And ActiveCell.Offset(0, -1).Value, vbokay)
            ActiveCell.Offset(1, 0).Select
    End If
    
End Sub

I am not getting the message box with the PO number in the last line of code, however, 1 line immediately after the asterisks is being completed with no problem.


Any help is greatly appreciated....


Thanks!
Ben
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Guessing that the cell you are adding 1 to here

ActiveCell.Offset(0, -1) = ActiveCell.Offset(-1, -1).Value + 1

is not numeric
 
Upvote 0
Okay, I checked that column, reformated everything in that column to "number" format, retyped information in that cell and I'm still getting the error. I am getting the date to fill in now, however, the username did not fill in.

Any other ideas?
 
Upvote 0
This line:

un = Environ("USERAME")

should be:

un = Environ("USERNAME")
 
Upvote 0
Okay, the type-o was causing my username not show up, that's fixed.

However, after fixing that I was still getting the problem. Did a little more research, found another example of a msgbox displaying some text and a cell value and found that using "&" instead of "And" in the PO display msgbox solves the problem.


Thanks for the help...

Ben
 
Upvote 0

Forum statistics

Threads
1,203,120
Messages
6,053,626
Members
444,674
Latest member
Fieldy1999

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