Results 1 to 11 of 11

How To Set A ListBox Selection As A Sheet Array

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    How To Set A ListBox Selection As A Sheet Array

    Hi all,

    in the following code, for testing purposes, I have success in writing the data from a userform to all 5 sheets as specified in MyArr...
    Private Sub PS1()
    Application.ScreenUpdating = False
    On Error Resume Next
    Dim MyArr As Variant
    Dim a As Long
    
    MyArr = Array("Round 1", "Round 2", "Round 3", "Round 4", "Round 5")
    For a = LBound(MyArr) To UBound(MyArr)
    Sheets(MyArr(a)).Select
    With Sheets(MyArr(a))
    
    Dim srNextRow&, strListBox1$, i%
    strListBox1 = ""
    LR = Cells(Rows.Count, "A").End(xlUp).Row + 1
    
    For i = 0 To ListBox21.ListCount - 1
    If ListBox21.Selected(i) = True Then strListBox1 = strListBox1 & ListBox21.List(i)
    Range("A" & LR & ".I" & LR).Value = Array(strListBox1, ListBox1.Text, TextBox15.Text, TextBox1.Text, TextBox11.Text, TextBox12.Text, TextBox16.Text, TextBox14.Text, TextBox13.Text)
    Next i
    
    End With
    Next a
    Application.ScreenUpdating = True
    End Sub
    What I would like to happen, however, is for the data to be written to one specific worksheet, that worksheet being one of the selections from a listbox (ListBox1 in this case). After trying some variations on ListBox.Selected, Listbox.ListCount, and ListBox.ListIndex, I'm no closer to getting it to work, and again, I think I'm just having problems with the syntax of it all.

    ListBox1 Item 1 = Round 1
    ListBox1 Item 2 = Round 2
    etc

    Anyone got some suggestions for me?

    Cheers,

    AJ
    Last edited by ScotyB; 12-03-2013 at 11:31 PM. Reason: to mark as solved
    Always grateful for the help here - thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] listbox item selection to got to specific sheet
    By sumonrezadu in forum Excel General
    Replies: 14
    Last Post: 05-17-2013, 12:38 AM
  2. VBA - Can I populate a listbox from an array taken from a listview selection
    By PDIreland in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2012, 06:28 AM
  3. Multi select Listbox Items selection based on other Listbox item selection.
    By srinivassathi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2011, 05:53 AM
  4. Replies: 3
    Last Post: 02-17-2011, 01:40 PM
  5. ListBox Value Selection Placement on Sheet
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-08-2010, 06:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1