How to determine the Order in Which Selections are Made in listbox by the user?

Home Forums VBA Forum (Visual Basic for Applications Community Support) How to determine the Order in Which Selections are Made in listbox by the user?

Tagged: , ,

This topic contains 0 replies, has 1 voice, and was last updated by Nikhil Nilaya Nikhil Nilaya 2 months, 1 week ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #8046
    Nikhil Nilaya
    Nikhil Nilaya
    Participant

    Hi ,
    I am trying to determine the Order in Which Selections are Made in listbox by the user ( Excel VBA), So far am able to populate selected into column A but selection order is missing, below is the code – also attached file for your reference.

    Private Sub CommandButton2_Click()

    ThisWorkbook.Sheets(“Sheet2”).Range(“A1:A10”).Select
    Selection.Cells.Clear
    Dim msg As String

    For X = 0 To ListBox1.listCount – 1

    If ListBox1.Selected(X) = True Then
    msg = msg & “,” & ListBox1.List(X) & vbCrLf
    End If

    Next X

    ThisWorkbook.Sheets(“Sheet2”).Range(“A1”).Value = msg

    Dim X1 As Variant
    X1 = Split(Range(“A1”).Value, “,”)
    On Error Resume Next
    Range(“A2”).Resize(UBound(X1) – LBound(X1) + 1).Value = Application.Transpose(X1) Cells.WrapText = False ThisWorkbook.Sheets(“Sheet2”).Range(“A1:A2”).Select
    Selection.Cells.Clear
    ThisWorkbook.Sheets(“Sheet2”).Range(“B2”).Value = Application.WorksheetFunction.CountA(ThisWorkbook.Sheets(“Sheet2”).Range(“A3:A10”))
    ThisWorkbook.Sheets(“Sheet2”).Range(“A3”).Select
    End Sub

    thanks a lot for the help

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Comments are closed.