Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Action on Multiselect Listbox

Hello Dearest Wizards,

I have been able to load my listbox ... with Items in Column A:

Private Sub Worksheet_Activate()
Dim cell As Range
Dim Rng As Range

'Me.ListBox1.ListFillRange = ""
'Me.ListBox1.Clear

With ThisWorkbook.Sheets("Sheet1")
Set Rng = .Range("a1", .Range("a1").End(xlDown))
End With

For Each cell In Rng.Cells
Me.ListBox1.AddItem cell.Value
Next cell
End Sub

My Problems:
1. Upon loading I would like to keep the items which were checked
already!
2. Above procedure adds again the same list to the already existing (if
you do not clear it ...)
Main Issue:
3. On each "check item" i would like to run a macro. Like:

Select Case
case1 item1 checked? then Run Macro1
case2 item2 not_checked then nothing
case3 item3 checked? run Macro3

End Select

- Ok my nr of items in the listbox can vary and my selection (of
macros) to be activated limited; but: If Nothing then MsgBox "no macro
assigned"

Any experienced wizard to help me out? Sige

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default Action on Multiselect Listbox

You can load your list without looping:
Private Sub UserForm_Initialize()
Me.ListBox1.List = Application.Transpose(Range(Range("A1"),
Range("A1").End(xlDown)))
End Sub

you can run the macros with each click with:
Private Sub ListBox1_change()
Application.Run "Macro" & Me.ListBox1.ListIndex + 1
End Sub

and you'd need a macro for each one, if that's what you want, in a regular
module
Sub macro1()
....
end sub

etc

but it'd be better to run the same macro & pass a parameter, like
Private Sub ListBox1_change()
MyMacro me.listbox1.listindex+1
End Sub

in regular module:
Sub MyMacro(MyNum as integer)
Select case MyNum
Case 1
....
Case 2
...
'etc.
End Select
End Sub

Bob Umlas


"Sige" wrote in message
ups.com...
Hello Dearest Wizards,

I have been able to load my listbox ... with Items in Column A:

Private Sub Worksheet_Activate()
Dim cell As Range
Dim Rng As Range

'Me.ListBox1.ListFillRange = ""
'Me.ListBox1.Clear

With ThisWorkbook.Sheets("Sheet1")
Set Rng = .Range("a1", .Range("a1").End(xlDown))
End With

For Each cell In Rng.Cells
Me.ListBox1.AddItem cell.Value
Next cell
End Sub

My Problems:
1. Upon loading I would like to keep the items which were checked
already!
2. Above procedure adds again the same list to the already existing (if
you do not clear it ...)
Main Issue:
3. On each "check item" i would like to run a macro. Like:

Select Case
case1 item1 checked? then Run Macro1
case2 item2 not_checked then nothing
case3 item3 checked? run Macro3

End Select

- Ok my nr of items in the listbox can vary and my selection (of
macros) to be activated limited; but: If Nothing then MsgBox "no macro
assigned"

Any experienced wizard to help me out? Sige



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Action on Multiselect Listbox


Thx a lot Bob,
I think I will get my way through with this!

Sige

"NOSPAM" to be removed for direct mailing...

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Action on Multiselect Listbox


Hi Bob,

I am working though with List-Items which I can check/ un-check.

So each List-item can get a True or False-status.
Like:
Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Run "Do"
Else
Run "UnDo"
End If
End Sub

How do I read , and keep the status in a listbox?
Cheers Sige

"NOSPAM" to be removed for direct mailing...

*** Sent via Developersdex http://www.developersdex.com ***
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
Multiselect Listbox use RKS Excel Discussion (Misc queries) 1 May 12th 06 03:04 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
multiselect listbox CG Rosén Excel Programming 2 December 28th 03 05:17 PM


All times are GMT +1. The time now is 07:30 PM.

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"