ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Identify which List Box was used (https://www.excelbanter.com/excel-programming/435526-identify-list-box-used.html)

jjb[_2_]

Identify which List Box was used
 
I use the same code connected to several List Boxes. I need the code to
determine which List Box was used to trigger the code. Not sure how I capture
that ListBox name.
Thanks,

joel[_119_]

Identify which List Box was used
 

Private Sub ListBox1_Click()

Set bx = ActiveSheet.OLEObjects("Listbox1")
Call CommonBox(bx)
End Sub
Private Sub ListBox2_Click()

Set bx = ActiveSheet.OLEObjects("Listbox2")
Call CommonBox(bx)
End Sub

Sub CommonBox(bx)

'enter code here
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=148748


Dave Peterson

Identify which List Box was used
 
If you used listboxes from the control toolbox toolbar, then you should know
what one triggered the code.

If you used listboxes from the Forms toolbar, then you could use:

Dim LB As ListBox
Set LB = ActiveSheet.ListBoxes(Application.Caller)
MsgBox LB.Name & vbLf & LB.TopLeftCell.Address

These are listboxes placed on the worksheet, right?

jjb wrote:

I use the same code connected to several List Boxes. I need the code to
determine which List Box was used to trigger the code. Not sure how I capture
that ListBox name.
Thanks,


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com