Select Whole List or Items in List Box

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.
 
B

Bob Phillips

Dim i As Long

With Me.ListBox1

.MultiSelect = fmMultiSelectExtended
For i = 1 To .ListCount

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

K

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.
 
K

K

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
 
H

Harald Staff

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
 
K

K

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
 
Top