Consulting

Results 1 to 3 of 3

Thread: Updating Menu

  1. #1

    Updating Menu

    Okay. I have a userform that makes employee records. The employee data is contained in columns A, B, and C, and starts on Row 2 and extends downward. My form has various comboboxes. The employee name combo box dynamically extends/shrinks as people are added. I'm trying to make it so that when a name is selected, it autopops the other information. That part currently works. However, whenever you add/remove a person, and the information resets, (cmbEmpName.value = "") it errors.

    I was debugging it, and after I removed a person, the name combobox still stored there name as a value, but the find statement was coming up with nothing, and it was erroring on that.

    Private Sub cmbEmpName_Change()
        Dim myRange, findRange As Range
        If Not cmbEmpName.Value = "" Then
            With ThisWorkbook.Sheets(5)
                Set myRange = .Range("A2", .Cells(Rows.Count, "A").End(xlUp))
                Set findRange = myRange.Find(Me.cmbEmpName.Value, MatchCase:=True)
                If Not findRange Is Nothing Then
                    myRange.Select
                    cmbShiftType.Value = findRange.Offset(0, 1).Value
                    cmbSchedType.Value = findRange.Offset(0, 2).Value
                End If
            End With
        End If
    End Sub
    Example attached in Zip.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    .
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    I found it. Instead of using the change method of the combobox, I used the AfterUpdate method, which more directly responds to a user-entry. Using the change method caused it to autopop as soon as they entered something in, which was bad if they were entering a new record.

Posting Permissions

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