LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default MultiSelect ListBox Help

Hello everyone,
I havent received a response on my original posting, so I thought I would
try again.

I need to find a way for VBA to accept the text of items chosen from a
MultiSelect listbox as either sheet names or named ranges.
------------------------------------------
Code I posted in my original posting:
Private Sub CommandButton2_Click()

Dim res As Variant
Dim Last As Integer

For i = 0 To Change_Region.ListBox1.ListCount - 1
If Change_Region.ListBox1.Selected(i) Then
res = Application.VLookup(Change_Region.ListBox1.Text = i,
Worksheets("LISTS").Range("Regions"), 1, False)
If Not IsError(res) Then
Last = Columns("A:A").Find(What:="", LookAt:=xlWhole).Row
Change_Region.Hide
Application.ScreenUpdating = False
Worksheets(res).Select
Worksheets(res).Range(i).Copy Worksheets("Master").Range(Last +
1, 1)
Else
Change_Region.Hide
MsgBox "Match not made. Please try again."
Change_Region.Show
End If
Else
Change_Region.ListBox1.Clear
MsgBox "Please choose a region or click Cancel."
End If
Next i

End Sub
------------------------------------------
Altered code based on research:
Private Sub CommandButton2_Click()

Dim selCount As Long: selCount = 0
Dim selItems() As String
Dim ndx As Long
Dim arrndx As Long

selCount = selCount + 1
arrndx = 0
ReDim selItems(0 To selCount - 1)

For i = 0 To Change_Region.ListBox1.ListCount - 1
If Change_Region.ListBox1.Selected(i) = True Then
selItems(arrndx) = ListBox1.List(i)
arrndx = arrndx + 1
Application.VLookup(arrndx,
Worksheets("LISTS").Range("RegionRange"), 4, False) = k
Application.Goto (k)
Change_Region.Hide
Application.ScreenUpdating = False
Selection.Copy
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select 1
ActiveSheet.Paste
Else
Change_Region.Hide
MsgBox "Please choose a region or click Exit."
Change_Region.Show
End If
Next i
------------------------------------------
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiselect Listbox use RKS Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM
Bug in multiselect listbox? Jos Vens[_2_] Excel Programming 2 February 8th 06 08:41 PM
MultiSelect ListBox StephanieH Excel Programming 5 November 20th 04 12:29 AM
Multiselect Listbox Francis Ang[_3_] Excel Programming 0 October 27th 04 02:21 AM
Multiselect Listbox Francis Ang[_3_] Excel Programming 2 October 25th 04 01:57 AM


All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"