Select Whole List or Items in List Box

  • Thread starter Thread starter K
  • Start date Start date
K

K

Hi all, I need macro on a button which can select all the items or
list in ListBox1. Please can any friend can help.
 
Dim i As Long

With Me.ListBox1

.MultiSelect = fmMultiSelectExtended
For i = 1 To .ListCount

.Selected(i - 1) = True
Next i
End With
 
Dim i As Long

    With Me.ListBox1

        .MultiSelect = fmMultiSelectExtended
        For i = 1 To .ListCount

            .Selected(i - 1) = True
        Next i
    End With

--
__________________________________
HTH

Bob






- Show quoted text -

Thanks lot Bob.
 
Dim i As Long

    With Me.ListBox1

        .MultiSelect = fmMultiSelectExtended
        For i = 1 To .ListCount

            .Selected(i - 1) = True
        Next i
    End With

--
__________________________________
HTH

Bob






- Show quoted text -

Bob do you know that what sort of adjusment I should make in your
macro if I want to select all the items or list in ListBox1 except the
last item
 
Dim i As Long

With Me.ListBox1

.MultiSelect = fmMultiSelectExtended
For i = 1 To .ListCount

.Selected(i - 1) = True
Next i
End With

--
__________________________________
HTH

Bob






- Show quoted text -

Bob do you know that what sort of adjusment I should make in your
macro if I want to select all the items or list in ListBox1 except the
last item

For i = 1 To .ListCount - 1

HTH. Best wishes Harald
 
Bob do you know that what sort of adjusment I should make in your
macro if I want to select all the items or list in ListBox1 except the
last item

For i = 1 To .ListCount - 1

HTH. Best wishes Harald- Hide quoted text -

- Show quoted text -

thanks Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top