Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Reading List Box Value

I will guess the listbox is from the forms toolbar instead of the control
toolbox toolbar

and Listbox_click is assigned to the listbox.


Sub Listbox_click()
dim sName as String
dim lbox as Listbox

sName = Application.Caller
set lbox = Activesheet.Listboxes(sName)

with lbox
msgbox sname & ": " & .list(.listindex)
End With


End Sub

--
Regards,
Tom Ogilvy


Bob Wilcox wrote in message
...
Hello,

In one module, I have sucessfully created and populated a
listbox on a worksheet. My last LOC in that module is to
Set objListBox = Nothing.

However, in the module, "ListBox_Click" (which does
display a MsgBox when clicked), I cannot determine the
values of the clicked data. Question, do I use Shapes,
Controls or somthing else? What and how do I set the
object?

B Wilcox




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Reading List Box Value

I used the command:

Set objListBox = .Shapes.AddFormControl(xlListBox, 400,
10, 100, 400)

to create the list box.



-----Original Message-----
I will guess the listbox is from the forms toolbar

instead of the control
toolbox toolbar

and Listbox_click is assigned to the listbox.


Sub Listbox_click()
dim sName as String
dim lbox as Listbox

sName = Application.Caller
set lbox = Activesheet.Listboxes(sName)

with lbox
msgbox sname & ": " & .list(.listindex)
End With


End Sub

--
Regards,
Tom Ogilvy


Bob Wilcox wrote in message
...
Hello,

In one module, I have sucessfully created and populated

a
listbox on a worksheet. My last LOC in that module is

to
Set objListBox = Nothing.

However, in the module, "ListBox_Click" (which does
display a MsgBox when clicked), I cannot determine the
values of the clicked data. Question, do I use Shapes,
Controls or somthing else? What and how do I set the
object?

B Wilcox




.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Reading List Box Value

Yes, that produces a Listbox from the forms toolbar. My code works with
that.

Here is an example:

Sub Macro1()
Dim objListbox As Object
For Each shp In ActiveSheet.Shapes
shp.Delete
Next
With ActiveSheet
Set objListbox = .Shapes. _
AddFormControl(xlListBox, 400, 10, 100, 400)
End With
objListbox.ControlFormat.ListFillRange = _
"Sheet1!A1:A10"
ActiveSheet.ListBoxes(objListbox.Name) _
.OnAction = "Listbox_click"

End Sub


Sub Listbox_click()
Dim sName As String
Dim lbox As ListBox

sName = Application.Caller
Set lbox = ActiveSheet.ListBoxes(sName)

With lbox
MsgBox sName & ": " & .List(.ListIndex)
End With


End Sub

--
Regards,
Tom Ogilvy

"b wilcox" wrote in message
...
I used the command:

Set objListBox = .Shapes.AddFormControl(xlListBox, 400,
10, 100, 400)

to create the list box.



-----Original Message-----
I will guess the listbox is from the forms toolbar

instead of the control
toolbox toolbar

and Listbox_click is assigned to the listbox.


Sub Listbox_click()
dim sName as String
dim lbox as Listbox

sName = Application.Caller
set lbox = Activesheet.Listboxes(sName)

with lbox
msgbox sname & ": " & .list(.listindex)
End With


End Sub

--
Regards,
Tom Ogilvy


Bob Wilcox wrote in message
...
Hello,

In one module, I have sucessfully created and populated

a
listbox on a worksheet. My last LOC in that module is

to
Set objListBox = Nothing.

However, in the module, "ListBox_Click" (which does
display a MsgBox when clicked), I cannot determine the
values of the clicked data. Question, do I use Shapes,
Controls or somthing else? What and how do I set the
object?

B Wilcox




.



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
Reading a list of names to update their records Tom Excel Discussion (Misc queries) 1 December 3rd 09 10:20 PM
reading from SQL Texas Tonie[_2_] Excel Discussion (Misc queries) 0 November 9th 07 10:59 PM
Reading XML Ajit Excel Discussion (Misc queries) 1 October 2nd 07 10:54 PM
Reading List Box Value Dave Peterson[_3_] Excel Programming 1 September 25th 03 01:43 PM
sub for reading Fernando Duran Excel Programming 4 September 15th 03 07:52 PM


All times are GMT +1. The time now is 02:20 PM.

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"