Multiselect userform box deselecting selected items

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
571
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
I have a userform with a couple listboxes... the second is enabled for multiselect.
When I click 2 or more items and it gets to this code, it does what I want it to do for the first one... but it "forgets" or deselects the rest of the selections...
Any suggestions?

VBA Code:
For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) = True Then
            guts.Select
            putItHere = guts.Range("daClients").Offset(i + 1, 1).Value
            backStage.Select
            backStage.Cells(putItHere, Range("dataList[[#Headers],[Action]]").Column).Value = "X"
        End If
        'If ListBox1.Selected(i) = False Then guts.Range("daFirms").Offset(i + 1, 1).Value = ""
    Next i
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I found aworkaround... this took care of it.

VBA Code:
Set TxtRng = guts.Range("daClients").Offset(1, 2)
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) Then
            TxtRng.Value = ListBox2.List(i)
            Set TxtRng = TxtRng.Offset(1)
        End If
    Next i

It added a few steps, but will do...
If you DO have a solution to my initial, I would welcome it.
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,967
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top