I have windows XP with Microsoft Excel 2003. When I run my code, it works fine. One of my coworkers has Windows 2000 and Microsoft Excel 97 SR-2 and she gets a Runtime Error 13 - Type Mismatch when it runs through the program.
The msgboxes open, but then she gets the runtime error when she clicks ok... I dont know what is wrong? Could anyone take a look at the code below and help? I am pretty sure it has something to do with the versions of excel, but I am not sure... I need to make it run on all versions as our company is not standardized.
The msgboxes open, but then she gets the runtime error when she clicks ok... I dont know what is wrong? Could anyone take a look at the code below and help? I am pretty sure it has something to do with the versions of excel, but I am not sure... I need to make it run on all versions as our company is not standardized.
Code:
Private Sub CommandButton1_Click()
'verifies the order form is accurate and complete
'unprotects the worksheet
Dim password
password = "6114"
Range("A1").Select
Application.ScreenUpdating = False
ActiveSheet.Unprotect "password"
'VERIFIES THE ORDER AMOUNT AND TOTALS ENTERED ARE EQUAL
'verifies the order amount with the amount entered per denomination and notates if variance
Range("j21").Select
If ActiveCell.Value <> 0 Then
ans = MsgBox("The Order Amount and breakdown entered in denominations do not match - check totals entered", vbCritical + vbOKOnly)
End If
Range("j21").Select
'VERIFIES ORDER INFORMATION IS COMPLETE
'checks to make sure that either acct/loc or user id is provided
Range("G14").Select
If ActiveCell.Value = 1 Then
ans = MsgBox("Provide EITHER the Account and Location numbers OR the User ID", vbCritical + vbOKOnly)
If ans = vbOK Then Range("B12:e12").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Range("g12:J12").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Range("b14:e14").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
End If
'checks to make sure that both acct and location are provided
Range("G14").Select
If ActiveCell.Value = 2 Then
ans = MsgBox("The Account AND Location numbers must be provided.", vbCritical + vbOKOnly)
If ans = vbOK Then Range("B12:e12").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Range("g12:J12").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
End If
'checks to make sure the request date is provided
Range("B5").Select
If ActiveCell.Value = 0 Then
ans = MsgBox("Request Date must be provided.", vbCritical + vbOKOnly)
If ans = vbOK Then Range("B5:e5").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Else
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
End If
'checks to make sure the delivery date is providedRange("B20").Select
If ActiveCell.Value = 0 Then
ans = MsgBox("Delivery Date must be provided.", vbCritical + vbOKOnly)
If ans = vbOK Then Range("B20:e20").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Else
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
End If
'checks to make sure the bank name is provided
Range("B10").Select
If ActiveCell.Value = 0 Then
ans = MsgBox("Bank Name must be provided.", vbCritical + vbOKOnly)
If ans = vbOK Then Range("B10:e10").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Else
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
End If
'checks to make sure the location name is providedRange("G10").Select
If ActiveCell.Value = 0 Then
ans = MsgBox("Location Name must be provided.", vbCritical + vbOKOnly)
If ans = vbOK Then Range("G10:J10").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Else
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
End If
'clears error when acct/loc or userid are provided
Range("G14").Select
If ActiveCell.Value = 0 Then
If ans = vbOK Then Range("B12:e12").Select
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
Range("g12:J12").Select
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
Range("b14:e14").Select
With Selection.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
End If
'ORDER PASSES - READY FOR SUBMISSION
Dim a As Integer
a = 0
'checks all required feilds for values
If IsEmpty(Range("B5").Value) Then a = 1 'req date
If IsEmpty(Range("B10").Value) Then a = 1 'bank name
If IsEmpty(Range("G10").Value) Then a = 1 'location name
If Range("G14").Value <> 0 Then a = 1 'acct/loc or userid
If IsEmpty(Range("B20").Value) Then a = 1 'delivery date
If Range("G20").Value = 0 Then a = 1 'order amt
If Range("J21").Value <> 0 Then a = 1 'order total and breakdown match
'if all required info is available, the pass message
If a = 0 Then
msg = "ORDER IS READY FOR SUBMISSION"
msg = msg & vbLf & vbLf
msg = msg & "SAVE order and EMAIL to LateOrders@brinksinc.com"
ans = MsgBox(msg, vbCritical + vbOKOnly)
If ans = vbOK Then savefile
End If
'reprotects the worksheet
ActiveSheet.Protect "password", True, True, True
End Sub