Consulting

Results 1 to 11 of 11

Thread: Need Error Check

  1. #1
    VBAX Regular
    Joined
    Sep 2013
    Posts
    61
    Location

    Need Error Check

    I need to fire a message box "SKU Not on File" if the value of tsku is not found in the source worksheet.

    Private Sub cmdqf_Click() 'Populates worksheet automatically from listbox
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    Set ws = Worksheets("SKU LineUp")
    Dim nullstring
        Application.ScreenUpdating = False
         
        If tsku.Value = "" Or nullstring Then
            MsgBox "Please Enter SKU Number"
            
            tsku.SetFocus
           Exit Sub
        End If
            ws.AutoFilterMode = False
            ws.Range("b1:g1").AutoFilter Field:=1, Criteria1:="*" & tsku.Text & "*"
            
        With ws.AutoFilter.Range.Offset(1, 0)
            .Copy Sheets("Pop").Range("b1")
                    
        End With
     
            Me.lb1.List = Worksheets("POP").Cells(1, 1).CurrentRegion.Value
            Me.lb1.Selected(0) = True
            
            tsku.Value = ""
    End Sub
    Oldman
    "Older is not always wiser"

  2. #2
    You can populate a combobox with all valid SKU numbers.
    If the user selects one a 'not found' message is not necessary.

  3. #3
    VBAX Regular
    Joined
    Sep 2013
    Posts
    61
    Location
    Will this still allow a user to type in the complete SKU number and clear the combobox after the item is found?

    Do I simply make an array of the sku numbers for the combobox?

    BTW, much of this project is a result of your help
    Oldman
    "Older is not always wiser"

  4. #4
    Apparently the sku numbers reside in column B.
    I assume it contains only unique sku's.
    So you can populate the combobox using
    Combobox.list=columns(2).specialcells(2).Value
    Why would you like to clear the combobox ?

  5. #5
    VBAX Regular
    Joined
    Sep 2013
    Posts
    61
    Location
    Why should I. It should be blank when I open the userform. My mistake.

    Thank you
    Oldman
    "Older is not always wiser"

  6. #6
    Every time the userform is loaded the combobox is empty by default.

  7. #7
    VBAX Regular
    Joined
    Sep 2013
    Posts
    61
    Location
    Correct
    Oldman
    "Older is not always wiser"

  8. #8
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Thread Solved? See Thread Tools.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  9. #9
    VBAX Regular
    Joined
    Sep 2013
    Posts
    61
    Location
    Thank you for the reminder. Just like being at home.
    Oldman
    "Older is not always wiser"

  10. #10
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Us ole pharts gotta help each other keep the olds-himers in check, ya no?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  11. #11
    VBAX Regular
    Joined
    Sep 2013
    Posts
    61
    Location
    Too funny
    Oldman
    "Older is not always wiser"

Posting Permissions

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