How to populate data from a range (multiple rows and columns) to listbox with VBA

前端 未结 3 1065
长情又很酷
长情又很酷 2021-01-14 09:23

I am having trouble with how to put the data from the range with multiple columns and rows to a listbox.

Assume I have a range rng which multiple columns and rows I

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-14 09:44

    You can use foreach to add items to the list box

    ActiveSheet.Shapes("lstSample").Select
    
    Dim currRange As Range
    With Selection
        For Each currRange In Range("yourRange")
            .AddItem currRange.Value
        Next
    End With
    

    For each itself iterates through each row and column in your range.

提交回复
热议问题