WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Constant execution of ListBox.Click

 
   Home -> Office -> General Discussions RSS
Next:  Validate cell for date, as well as day of the wee..  
Author Message
Curious George

External


Since: Nov 18, 2008
Posts: 1



(Msg. 1) Posted: Tue Nov 18, 2008 11:38 am
Post subject: Constant execution of ListBox.Click
Archived from groups: microsoft>public>excel (more info?)

How do I constantly make events fire, like ListBox.Click subroutine.
Currently I can run the result only by executing the macro run button
thingie. Cant I make the VBA work all the time without pressing any
buttons to run the code?
Back to top
Login to vote
Dave Peterson

External


Since: Jul 08, 2005
Posts: 9018



(Msg. 2) Posted: Tue Nov 18, 2008 3:01 pm
Post subject: Re: Constant execution of ListBox.Click [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Personally, I like having to click the button after making the selection in the
listbox, but maybe you could use a different event.

I created a userform with a listbox and then used the _MouseUp event.

Option Explicit
Private Sub ListBox1_MouseUp(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
MsgBox Me.ListBox1.Value
Me.ListBox1.ListIndex = -1
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.ListBox1
For iCtr = 1 To 5
.AddItem "asdf" & iCtr
Next iCtr
End With
End Sub

Curious George wrote:
>
> How do I constantly make events fire, like ListBox.Click subroutine.
> Currently I can run the result only by executing the macro run button
> thingie. Cant I make the VBA work all the time without pressing any
> buttons to run the code?

--

Dave Peterson
Back to top
Login to vote
Harald Staff

External


Since: Sep 26, 2007
Posts: 113



(Msg. 3) Posted: Tue Nov 18, 2008 9:28 pm
Post subject: Re: Constant execution of ListBox.Click [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

ListBox_Click will run when and only when a different listbox selection is
made in this very listbox. That is the whole point of events. If you want
sonething to happen all the time then program it to happen all the time,
don't use events.

HTH. Best wishes Hrald


"Curious George" <Jakesama.TakeThisOut@gmail.com> wrote in message
news:3aefc58b-5ff9-46fe-be98-07de894f1f33@n33g2000pri.googlegroups.com...
> How do I constantly make events fire, like ListBox.Click subroutine.
> Currently I can run the result only by executing the macro run button
> thingie. Cant I make the VBA work all the time without pressing any
> buttons to run the code?
Back to top
Login to vote
Curious George

External


Since: Nov 17, 2008
Posts: 4



(Msg. 4) Posted: Tue Nov 18, 2008 11:14 pm
Post subject: Re: Constant execution of ListBox.Click [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Harald Staff wrote:
> ListBox_Click will run when and only when a different listbox selection
> is made in this very listbox. That is the whole point of events. If you
> want sonething to happen all the time then program it to happen all the
> time, don't use events.
>
> HTH. Best wishes Hrald
>
>
> "Curious George" <Jakesama.TakeThisOut@gmail.com> wrote in message
> news:3aefc58b-5ff9-46fe-be98-07de894f1f33@n33g2000pri.googlegroups.com...
>> How do I constantly make events fire, like ListBox.Click subroutine.
>> Currently I can run the result only by executing the macro run button
>> thingie. Cant I make the VBA work all the time without pressing any
>> buttons to run the code?
>

I want the code to execute exactly when the different selections are
made. But it just doesn't do it.
Back to top
Login to vote
Curious George

External


Since: Nov 17, 2008
Posts: 4



(Msg. 5) Posted: Tue Nov 18, 2008 11:16 pm
Post subject: Re: Constant execution of ListBox.Click [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Dave Peterson wrote:
> Personally, I like having to click the button after making the selection in the
> listbox, but maybe you could use a different event.
>
> I created a userform with a listbox and then used the _MouseUp event.
>
> Option Explicit
> Private Sub ListBox1_MouseUp(ByVal Button As Integer, _
> ByVal Shift As Integer, _
> ByVal X As Single, _
> ByVal Y As Single)
> MsgBox Me.ListBox1.Value
> Me.ListBox1.ListIndex = -1
> End Sub
> Private Sub UserForm_Initialize()
> Dim iCtr As Long
> With Me.ListBox1
> For iCtr = 1 To 5
> .AddItem "asdf" & iCtr
> Next iCtr
> End With
> End Sub
>
> Curious George wrote:
>> How do I constantly make events fire, like ListBox.Click subroutine.
>> Currently I can run the result only by executing the macro run button
>> thingie. Cant I make the VBA work all the time without pressing any
>> buttons to run the code?
>

So using the toolbar and making just a simple listbox to the sheet wont
work, now I have to make a userform?
Back to top
Login to vote
Dave Peterson

External


Since: Jul 08, 2005
Posts: 9018



(Msg. 6) Posted: Tue Nov 18, 2008 11:16 pm
Post subject: Re: Constant execution of ListBox.Click [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Nope.

I guessed you were using a userform. You didn't share enough details in the
first post.

I used a listbox from the control toolbox toolbar and only put the _mouseup
event in that worksheet's module.

Don't include the userform_initialize code.



Curious George wrote:
>
> Dave Peterson wrote:
> > Personally, I like having to click the button after making the selection in the
> > listbox, but maybe you could use a different event.
> >
> > I created a userform with a listbox and then used the _MouseUp event.
> >
> > Option Explicit
> > Private Sub ListBox1_MouseUp(ByVal Button As Integer, _
> > ByVal Shift As Integer, _
> > ByVal X As Single, _
> > ByVal Y As Single)
> > MsgBox Me.ListBox1.Value
> > Me.ListBox1.ListIndex = -1
> > End Sub
> > Private Sub UserForm_Initialize()
> > Dim iCtr As Long
> > With Me.ListBox1
> > For iCtr = 1 To 5
> > .AddItem "asdf" & iCtr
> > Next iCtr
> > End With
> > End Sub
> >
> > Curious George wrote:
> >> How do I constantly make events fire, like ListBox.Click subroutine.
> >> Currently I can run the result only by executing the macro run button
> >> thingie. Cant I make the VBA work all the time without pressing any
> >> buttons to run the code?
> >
>
> So using the toolbar and making just a simple listbox to the sheet wont
> work, now I have to make a userform?

--

Dave Peterson
Back to top
Login to vote
Harald Staff

External


Since: Sep 26, 2007
Posts: 113



(Msg. 7) Posted: Wed Nov 19, 2008 4:20 pm
Post subject: Re: Constant execution of ListBox.Click [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Curious George" <digindom.RemoveThis@luukku.com> wrote in message
news:lfGUk.93956$_03.90731@reader1.news.saunalahti.fi...
> I want the code to execute exactly when the different selections are made.
> But it just doesn't do it.

Ok, there are listboxes and there are listboxes. The ones from Forms toolbar
doesn't have events. Assign a standard macro to it and it runs on click.
The ones from the Controls toolbox will not fire the Click event if it is
set to multiselect, use the Change event if so.

HTH. Best wishes Harald
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> General Discussions All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET