• Data Validation: Userforms & Combo Boxes (97 SR2)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Data Validation: Userforms & Combo Boxes (97 SR2)

    Author
    Topic
    #357518

    I’ve got several combo boxes on my userforms that use specific row sources. My question is, if an item the user enters is not in the combo box, is there any way to place it in a separate column?

    For example, if the user types in an office that is not in my list, can I pull this and put it into another column?

    Any help would be greatly appreciated!

    Viewing 0 reply threads
    Author
    Replies
    • #531255

      Hi Drk,

      Not entirely sure what you’re asking.

      >>can I pull this

      You can compare new item to combo list and if not found…

      >> and put it into another column?

      if test is true, you can designate the

      Cells(myRow, myCol) = cboBox.Text

      • #531258

        I’m missing everything but the if not in row source statement…

        Sub combobox_afterupdate() ‘<=- I assume this is the right syntax…
        'Comparison statement here…
        combobox.value = range("A" & i).value
        end sub

        I represents the current row, and is publicly declared and assigned elsewhere in the code.

        Any help would be greatly appreciated!

        • #531261

          Hi Drk,

          Sorry, I must be a bit confused, but I think you want
          to compare the typed value in the Combobox to the
          combobox list?

          Try this code:

          Private Function AlreadyListed(ListControl As Control, NewItem As String) As Boolean
          Dim i As Integer

          AlreadyListed = False

          For i = 0 To ListControl.ListCount – 1
          If UCase$(ListControl.List(i)) = UCase$(NewItem) Then AlreadyListed = True
          Next i
          End Function

          Private Sub cboOffice_AfterUpdate()
          If Not AlreadyListed(cboOffice, cboOffice.Text) Then
          ‘Do something here
          MsgBox “Not in the list”
          End If
          End Sub

    Viewing 0 reply threads
    Reply To: Data Validation: Userforms & Combo Boxes (97 SR2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: