View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_9_] Rowan[_9_] is offline
external usenet poster
 
Posts: 88
Default Macro for Control ListBox

If the listbox is from the Control Toolbox then this event should work
if placed in the code module for the sheet which holds the listbox:

Private Sub ListBox1_Click()
If Me.ListBox1.Value = "Equivalent kwh/yr" Then
Call Module4.togglequiv
ElseIf Me.ListBox1.Value = "Actual kwh/yr" Then
Call Module4.toggleact
End If
End Sub

Hope this helps
Rowan

Linking to specific cells in pivot table wrote:
Hi,

I have a List Box that I created from the Control Toolbox -- I am trying to
have a macro run based off of which value has been selected in the listbox
(there are only two values that can be selected). I tried the code below,
but am getting the following error: "Run-time error 438: Object doesn't
support this property or method".

If ActiveSheet.Object("ListBox1").Value = "Equivalent kwh/yr" Then
Call Module4.togglequiv
Else
If ActiveSheet.Object("ListBox1").Value = "Actual kwh/yr" Then
Call Module4.toggleact
End If
End If

Can someone let me know what the proper coding should be? Thanks for your
help!!

Robert