none
how can add combo box to the following userform RRS feed

  • Question

  • good greeting dears,

    i have userform and i want to add a combobox code to the following code ,how can i made it

    i have this code :

    Private Sub CommandButton5_Click() 'Search Button
    Sheet4.Activate
    Dim sat, s As Long
    Dim deg1, deg2 As String
    Application.ScreenUpdating = True
    If ComboBox6.Value = "" Then
    MsgBox "Please enter a value", vbExclamation
    ComboBox6.SetFocus
    Exit Sub
    End If

    With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    If ComboBox1.Value = "" Or ComboBox1.Value = "-" Then
    MsgBox "Choose a filter field", vbExclamation
    ComboBox1.SetFocus
    Exit Sub
    End If

    For A = 1 To 9 ' Clear textboxes(1-9)
    ComboBox2 = ""
    TextBox2 = ""
    ComboBox3 = ""
    ComboBox4 = ""
    ComboBox5 = ""
    TextBox6 = ""
    TextBox7 = ""
    TextBox8 = ""
    Next
    With ListBox1
    .Clear
    .ColumnCount = 9
    .ColumnWidths = "20;70;60;60;80;60;60;60;100"
    End With

    UserForm6.ComboBox5.BackColor = vbWhite


    deg2 = ComboBox6.Value
    Select Case ComboBox1.Value
    Case "ÇÓã ÇáãæÙÝ"
    For sat = 2 To Cells(Rows.Count, 2).End(xlUp).Row
    Set deg1 = Cells(sat, "B")
    If UCase(deg1) Like UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")
    s = s + 1
    End If: Next

    Case "ãßÇä ÇáãÚÇãáÉ"
    For sat = 2 To Cells(Rows.Count, 4).End(xlUp).Row
    Set deg1 = Cells(sat, "D")
    If UCase(deg1) Like UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")

    s = s + 1
    End If: Next

    Case "ÌåÉ ÇáãÚÇãáÉ"
    For sat = 2 To Cells(Rows.Count, 5).End(xlUp).Row
    Set deg1 = Cells(sat, "E")
    If UCase(deg1) Like UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")

    s = s + 1
    End If: Next

    Case "ÍÇáÉ ÇáãÚÇãáÉ"
    For sat = 2 To Cells(Rows.Count, 6).End(xlUp).Row
    Set deg1 = Cells(sat, "F")
    If UCase(deg1) Like UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")

    s = s + 1
    End If: Next

    End Select

    With Application
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    .EnableEvents = True
    End With

    Label15.Caption = ListBox1.ListCount
    ListBox1.SetFocus

    End Sub

    and i want to add a nother combo box for example ( combobox7) and creat a code for it to let the search button 

    search up to three condition not two

    how can creat this code for combobox7

    and adding this code to the code already a bove

    thanks 

    Thursday, February 7, 2019 5:53 AM

All replies

  • Hi TAREK SHARAF,

    Could you explain how many UserForm(s) are there, and where (on which UserForm or on which Sheet) Buttons are.
    i.e. I would like you to set your objects in order, in order for me to understand your issue.
    Or insert/share images of UserForm(s) and worksheet(s) related to your issue.

    Regard,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html


    • Edited by Ashidacchi Thursday, February 7, 2019 10:37 AM
    Thursday, February 7, 2019 10:35 AM
  • Thursday, February 14, 2019 5:52 AM
  • DEAR, 

    GOOD GREETING

    THIS IS THE LINK OF MY WORKBOOK

    https://drive.google.com/file/d/1yk-847b3H0T3yKJeczKg3J-M0FXgb7w5/view?usp=sharing


    Thursday, February 14, 2019 5:55 AM
  • Hi TAREK SHARAF,

    Thank you for sharing your file.
    I suppose it is a full spec file, i.e. it's original, not modified for others to see.

    I've opened it and made it editable, and just after that, found a Run-time error:

        UserForm3 / Private Sub UserForm_Initialize() / 
        rng = .Range("ba" & Rows.Count).End(xlUp).Row

    I'm a software developer (Windows applications, Excel VBA, etc), self-employed.
    Sorry, I cannot help you, unless you make your file/code more simple, i.e. I'd like you to remove Sheets / UserForms / VBA code which have no relation to your current issue, and then share it.   

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Thursday, February 14, 2019 10:12 AM