Posts by waimea

    Hi,


    I am trying to filter a multiple column listbox by a combobox and searching the same listbox with a textbox.


    My listbox is called listbox1. I want to select combobox1 and filter the listbox1 on column A.


    So if I select item "122-22-122" I want only items with "122-22-122" to show in the listbox.


    I am also trying to input text into textbox1 and press commandbutton1 and filter the listbox.


    So if I enter "555-21-777" it only shows items with that number.


    All controls are activex controls and on an userform called userform1.


    How can I do this in VBA?


    I have crossposted this at https://www.excelforum.com/exc…combobox-and-textbox.html

    I am using a ComboBox to make the user select a City. Based on the City chosen I would like to display neighboring cities in a chart.


    Ex. City1 has 4 neighbors, City 12, City 15, City 19 and City 25.


    I would like to see a chart with City1 , City 12, City 15, City 19 and City 25.


    If I select another City I would like to see that City's neighbours.


    I am thinking about doing a select case statement but I am not sure where to start???

    Thank you for your reply. This code works great with debug print. The linked cell of the ComboBox updates with this code.




    Code
    Sub IterateComboBox()
    Dim i As Long
      With Sheets("Jämföra").Län1
        For i = 0 To .ListCount - 1
        'Debug.Print .List(i)
        .Value = .List(i)
        Next
      End With
    End Sub


    ComboBox1 contains:


    Stockholms län
    Västra götalands län
    Skåne län
    Uppsala län
    Södermanlands län
    Östergötlands län
    Jönköpings län
    Kronobergs län
    Kalmar län
    Gotlands län
    Blekinge län
    Hallands län
    Värmlands län
    Örebro län
    Västmanlands län
    Dalarnas län
    Gävleborgs län
    Västernorrlands län
    Jämtlands län
    Västerbottens län
    Norrbottens län


    *The text above is the ouput in the immediate window from your code

    Code
    Option Explicit  Sub LoopThroughValidationList()     Dim lst As Variant     Dim rCl As Range     Dim str As String     Dim iX As Integer      str = Range("B1").Validation.Formula1     On Error GoTo exit_proc:     If Left(str, 1) = "=" Then         str = Right(str, Len(str) - 1)         For Each rCl In Worksheets(Range(str).Parent.Name).Range(str).Cells             Range("B1").Value = rCl.Value         Next rCl     Else         lst = Split(str, ",")         For iX = 0 To UBound(lst)             Range("B1").Value = lst(iX)         Next iX     End If     Exit Sub exit_proc:     MsgBox "No validation list ", vbCritical, "Error" End Sub

    Hi, I have found the following code at https://www.ozgrid.com/forum/forum/h...cro+validation



    Option Explicit
    Sub LoopThroughValidationList()


    Dim lst As Variant
    Dim rCl As Range
    Dim str As String
    Dim iX As Integer


    str = Range("B1").Validation.Formula1
    On Error GoTo exit_proc:
    If Left(str, 1) = "=" Then
    str = Right(str, Len(str) - 1)
    For Each rCl In Worksheets(Range(str).Parent.Name).Range(str).Cells
    Range("B1").Value = rCl.Value
    Next rCl
    Else
    lst = Split(str, ",")
    For iX = 0 To UBound(lst)
    Range("B1").Value = lst(iX)
    Next iX
    End If
    Exit Sub
    exit_proc:
    MsgBox "No validation list ", vbCritical, "Error"
    End Sub



    Could someone help me modify the code to select items from 2 or more data validation lists and copying a range from active worksheet to a new worksheet in every loop?

    In this thread https://www.ozgrid.com/forum/forum/h...value?t=190022 a macro is given to loop through a data validation drop down.


    I am looking to do the same, however I have 4 dropdowns.


    1. Select FirstItem1 in Dropdown1
    2. Select FirstItem2 in Dropdown2
    3. Copy and/or count a specific range of cells with the countif formula
    4. Save the result of the copy and/or count
    5. Write the result in a new worksheet of FirstItem1 and FirstItem2
    6. Goto 1
    7. Select SecondItem1 in Dropdown1
    8. Select SecondItem2 In Dropdown2
    etc.

    Hi,


    I found this webpage http://www.thesmallman.com/blo…-non-dependent-comboboxes and I would like help to understand the code and ultimately modify the code to suit my needs.




    I want to modify this code to give me 4 ComboBoxes where ComboBox1 and ComboBox2 are identical and where ComboBox3 and ComboBox4 are identical. I would like ComboBox3 and ComboBox4 to be dependent on ComboBox1 and ComboBox2.


    I am just beginning to learn VBA and any help is very much appreciated!


    /waimea