Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default MultiColumn ListBox, linked to a range - select cells

i have a multicolumn list box, "ListBox1", with this statement on it's click
event.
Private Sub ListBox1_Click()
If ListBox1.ListIndex < -1 Then
Rows(ListBox1.ListIndex + 2).Select
End If
End Sub

i have made this list box a MultiSelect listbox. how can i modify this code
to make it select the multiple rows as if the user was holding Ctrl and
selecting rows? TIA.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default MultiColumn ListBox, linked to a range - select cells

I changed the procedure to _change.

Option Explicit
Private Sub ListBox1_Change()

Dim iCtr As Long
Dim Rng As Range

For iCtr = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(iCtr) = True Then
If Rng Is Nothing Then
Set Rng = Cells(iCtr + 2, "A")
Else
Set Rng = Union(Cells(iCtr + 2, "A"), Rng)
End If
End If
Next iCtr

If Rng Is Nothing Then
'do nothing
Else
Rng.EntireRow.Select
End If

End Sub



Spencer Hutton wrote:

i have a multicolumn list box, "ListBox1", with this statement on it's click
event.
Private Sub ListBox1_Click()
If ListBox1.ListIndex < -1 Then
Rows(ListBox1.ListIndex + 2).Select
End If
End Sub

i have made this list box a MultiSelect listbox. how can i modify this code
to make it select the multiple rows as if the user was holding Ctrl and
selecting rows? TIA.


--

Dave Peterson
Reply
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
Multicolumn Listbox with variable range dht[_2_] Excel Programming 4 January 11th 05 06:18 PM
multicolumn listbox move or value set Andrew Smith Excel Programming 3 August 25th 04 05:18 AM
Reordering with Multicolumn Listbox asmenut Excel Programming 2 August 17th 04 01:53 PM
Multicolumn Listbox and ordinary listbox Ron_D Excel Programming 0 June 4th 04 08:56 PM
multicolumn Listbox and textalignment John Holland Excel Programming 3 September 11th 03 01:45 AM


All times are GMT +1. The time now is 02:45 AM.

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

About Us

"It's about Microsoft Excel"