Consulting

Results 1 to 4 of 4

Thread: Product List Search Function

  1. #1
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    3
    Location

    Product List Search Function

    Hi Everyone,

    I have been trying to put a search box in my product list for hours but couldn't succeed so far.

    This is the "product selection form":

    Private Sub AddItem_Click()
    
    'Turn off Screen Updating so updating of PO cannot be seen until finished.
    Application.ScreenUpdating = True
    
    'Declare relevant variables
    Dim CurrentProduct As String
    Dim ProductID As String
    Dim UnitPrice As Currency
    Dim ProductCategory 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 = 5
    
    '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)
    ProductCategory = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 3, False)
    
    'Populate next line item with product selection
    Range("C" & POrowstart + LineItemTotal).Value = ProductID
    Range("D" & POrowstart + LineItemTotal).Value = CurrentProduct
    Range("F" & POrowstart + LineItemTotal).Value = Quantity
    
    ' Reset Userform values to indicate item was added to PO
    QuantityBox.Value = ""
    labelProductName.Caption = "Ürün Tanımı: "
    labelProductID.Caption = "Stok Kodu: "
    labelProductCategory.Caption = "Ürün Kategorisi: "
    
    '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 = 20 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 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 ProductCategory As String
    
    'Grab current product from ProductList ListBox selection
    CurrentProduct = ProductList.Value
    
    'Change Product Name label to reflect current item.
    labelProductName.Caption = "Ürün Tanımı: " & CurrentProduct
    
    'Lookup Product ID based on Product Description and change label
    ProductID = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 2, False)
    labelProductID.Caption = "Stok Kodu: " & ProductID
    
    'Lookup Product Category based on Product Description and change label
    ProductCategory = Application.WorksheetFunction.VLookup(CurrentProduct, Range("ProductListing"), 3, False)
    labelProductCategory.Caption = "Ürün Kategorisi: " & ProductCategory
    
    'Lookup Unit Price based on Product Description and change label
    
    End Sub
    I need to put a search box on it. So, when a letter is pressed, it filters only these products.
    Secondly, I'm trying to use mouse wheels in the list but it doesn't work.

    Any help would be appreciated.

    Thanks!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    it'd be easier to see if you could attach an example workbook with the userform and the macros.

    My sig has instructions for attaching a file
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    3
    Location

    Post Example Workbook

    Here is the example workbook.
    I need to search on product selection screen.
    There are lots of items in product list page, but I removed them for example workbook.
    Thank you for your concern.
    Attached Files Attached Files

  4. #4
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    3
    Location
    Is there anyone who can help?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •