Here is the code I have written in the rest of the Generator... Maybe this will help as well. I have no idea.
Private Sub AddItem_Click()
'Turn off Screen Updating so updating of PO cannot be seen until finished.
Application.ScreenUpdating = False
'Declare relevant variables
Dim CurrentProduct As String
Dim ProductID As String
Dim UnitPrice As Currency
Dim Vendor As String
Dim Quantity As Integer
Dim LineItemTotal As Integer
Dim POrowstart As Integer
'Information regarding which row to start with for PO
LineItemTotal = Range("LineItemTotal").Value
POrowstart = 10
'Get current product selection information from the 'ProductSelection' UserForm
CurrentProduct = ProductList.Value
Quantity = QuantityBox.Value
'Lookup related product information from the ProductListing range
ProductID = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 2, False)
Vendor = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 3, False)
UnitPrice = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 4, False)
'Populate next line item with product selection
Range("B" & POrowstart + LineItemTotal).Value = Quantity
Range("C" & POrowstart + LineItemTotal).Value = ProductID
Range("D" & POrowstart + LineItemTotal).Value = CurrentProduct
Range("M" & POrowstart + LineItemTotal).Value = UnitPrice
Range("L" & POrowstart + LineItemTotal).Value = Vendor
' Reset Userform values to indicate item was added to PO
QuantityBox.Value = ""
labelProductName.Caption = "Product Name: "
labelProductID.Caption = "Product ID: "
labelVendor.Caption = "Vendor: "
labelUnitPrice.Caption = "Unit Price:"
'Since PO only has 5 line items, needs to end program if 5 have been selected. See homework for additional assignment for higher items.
If LineItemTotal = 29 Then
MsgBox "Your Purchase Order is complete."
Unload Me
End If
End Sub
Private Sub FinishOrder_Click()
'Exit Macro
Unload Me
End Sub
Private Sub labelProductCategory_Click()
End Sub
Private Sub ProductList_Click()
'This macro runs when an item in the Product Selection listbox is selected
'Declare relevant variables
Dim CurrentProduct As String
Dim ProductID As String
Dim UnitPrice As Currency
Dim Vendor As String
'Grab current product from ProductList ListBox selection
CurrentProduct = ProductList.Value
'Change Product Name label to reflect current item.
labelProductName.Caption = "Product Name: " & CurrentProduct
'Lookup Product ID based on Product Description and change label
ProductID = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 2, False)
labelProductID.Caption = "Product ID: " & ProductID
'Lookup Product Category based on Product Description and change label
Vendor = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 3, False)
labelVendor.Caption = "Vendor: " & Vendor
'Lookup Unit Price based on Product Description and change label
UnitPrice = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 4, False)
labelUnitPrice.Caption = "Unit Price: $" & UnitPrice
End Sub