Teqlump2002
Computer
- Dec 8, 2002
- 2
I have an Excel document that I am adding VBA code for and I need to display the values of two variables in the message box so the user can see what the remaining stock values are for a certain product when they place an order. I entered the commands in just as my reference book says but the message box doesnt show the value of the variables. Does anybody know how to make this work. I have the code pasted below. Thanks a million.
Sub Insert_Order()
'
' Insert_Order Macro
'
'
Dim Item As String
Dim Ordered As Integer
Dim Instock As Integer
Dim Remaining As Integer
Item = Worksheets("Order Form".Range("C6".Value
Ordered = Worksheets("Order Form".Range("C8".Value
Instock = Application.WorksheetFunction.VLookup(Range("C5", Range("Inventory", 6, F)
Remaining = Instock - Ordered
If Remaining >= 0 Then
Sheets("Submitted Orders".Select
Rows("3:3".Select
Selection.Insert Shift:=xlDown
Sheets("Order Form".Select
Range("C4:C11".Select
Selection.Copy
Sheets("Submitted Orders".Select
Range("A3".Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("Order Form".Select
Range("C14:C19".Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Submitted Orders".Select
Range("I3".Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Range("A1".Select
Sheets("Order Form".Select
Range("C4".Select
Application.CutCopyMode = False
Selection.ClearContents
Range("C5".Select
Selection.ClearContents
Range("C8".Select
Selection.ClearContents
Range("C14:C19".Select
Selection.ClearContents
Range("C4".Select
MsgBox "You have Remaining Item remaining in stock.", vbInformation, "Order Entered"
Else
MsgBox "There are only Instock Item in stock.", vbCritical, "Order Rejected"
End If
End Sub
Sub Insert_Order()
'
' Insert_Order Macro
'
'
Dim Item As String
Dim Ordered As Integer
Dim Instock As Integer
Dim Remaining As Integer
Item = Worksheets("Order Form".Range("C6".Value
Ordered = Worksheets("Order Form".Range("C8".Value
Instock = Application.WorksheetFunction.VLookup(Range("C5", Range("Inventory", 6, F)
Remaining = Instock - Ordered
If Remaining >= 0 Then
Sheets("Submitted Orders".Select
Rows("3:3".Select
Selection.Insert Shift:=xlDown
Sheets("Order Form".Select
Range("C4:C11".Select
Selection.Copy
Sheets("Submitted Orders".Select
Range("A3".Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("Order Form".Select
Range("C14:C19".Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Submitted Orders".Select
Range("I3".Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Range("A1".Select
Sheets("Order Form".Select
Range("C4".Select
Application.CutCopyMode = False
Selection.ClearContents
Range("C5".Select
Selection.ClearContents
Range("C8".Select
Selection.ClearContents
Range("C14:C19".Select
Selection.ClearContents
Range("C4".Select
MsgBox "You have Remaining Item remaining in stock.", vbInformation, "Order Entered"
Else
MsgBox "There are only Instock Item in stock.", vbCritical, "Order Rejected"
End If
End Sub