Kamis, 19 Februari 2015

Re: [ExcelVBA] How do you get code assigned to a ListBox to run even when the same item is selected?

 

Thank you again, David.


When I tried your suggestion, I get an "Argument not optional" error when I pick something new from the list.   (The ListBox does show the new selection, but the statements within the Sub are not executed.)

When I pick the same item from the list, I don't get the error msg, but the statements are still not executed.

It seems like it should tell me WHICH argument is not optional.   I couldn't even find a good description of the syntax by googling "VBA Event syntax".   

Thanks again for looking at it.

Dunbar



---In ExcelVBA@yahoogroups.com, <yahoo@...> wrote :

No you need

Private Sub Game2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

The above should be all on one line.

Regards
David Grugeon


On 15 February 2015 at 03:04, h_dunbar@... [ExcelVBA] <ExcelVBA@yahoogroups.com> wrote:


Greetings!


I have a ListBox on Worksheet "PlayList".   When the macro below is assigned to the ListBox, it does what I want, as long as I choose an item on the list different from the previous selection:


<code> 

Sub Game2_Click()

  

      Range("ChangedGame2").Value = "Yes"

      UnProtectSheet ("PlayList")

        Range("CustomName1").Offset(0, 1).Value = ""

      ProtectSheet ("PlayList")


End Sub

</code>


But when I select the same (as previous) item from the drop-down list, nothing happens.  I have tried replacing "Click" with "AfterUpdate", "KeyPress", "BeforeUpdate", "Selection", and "Select"  (basically, everything I could find on Google, with the exception of "Kardashian").    With each of those events, the code runs only if I've picked a new item from the List.


How can I get that code to run every time I click on the ListBox?






__._,_.___

Posted by: h_dunbar@hotmail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar