+ Reply to Thread
Results 1 to 12 of 12

BeforeDoubleClick worksheet event on multiple ranges

  1. #1
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    BeforeDoubleClick worksheet event on multiple ranges

    Hi,
    I have this so far:
    Please Login or Register  to view this content.
    It works fine, but I'm sure there is a better way to write this.
    There will be many more ranges (50+ ranges) and they all "Call tpSelect" on doubleclick.
    I have tried "If Target.Address = Range("tp.A", "tp.B", ...).Address Then" but that doesn't work I guess.
    Oh and these are named ranges...

    Thanks in advance.
    Last edited by Leith Ross; 04-04-2015 at 09:27 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: BeforeDoubleClick worksheet event on multiple ranges

    Hello cocacrave,

    Welcome to the Forum!

    This should work...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Re: BeforeDoubleClick worksheet event on multiple ranges

    I have tried your solution. Thank you for posting.
    For some reason, it doesn't work.
    When I double click, it goes into edit mode instead of running the macro.
    Does it matter if the named ranges are merged cells?
    For example, A1:C4 has a name tp.A
    I have gotten it work with what I wrote above with these merged cells but it will be super long and messy.
    Any ideas why it's not working?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: BeforeDoubleClick worksheet event on multiple ranges

    Hello cocacrave,

    It is really difficult to diagnose the problem because I don't have a copy of your workbook. Running your code on my computer would help to isolate or eliminate potential problems.

    Please redact any sensitive or confidential information before you post the workbook.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,378

    Re: BeforeDoubleClick worksheet event on multiple ranges

    Either of these will work:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Re: BeforeDoubleClick worksheet event on multiple ranges

    Thank you, the first one didn't work but the second solution worked perfectly.

  7. #7
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Re: BeforeDoubleClick worksheet event on multiple ranges

    It turns out I can't even use your solution because of too many 24 line continuation limit which I did not even know about.
    I need atleast 1600+ line continuation to write it in this format.. I guess I just have to use what I wrote which is painfully long but atleast it isnt limited.
    Unless there's a workaround?

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: BeforeDoubleClick worksheet event on multiple ranges

    Hi cocacrave,
    maybe so
    Please Login or Register  to view this content.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,378

    Re: BeforeDoubleClick worksheet event on multiple ranges

    You don't have to use the line extensions as I have in the examples. That was really just to show the structure of the code.

    Please Login or Register  to view this content.
    ... works just as well


    Regards, TMS

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: BeforeDoubleClick worksheet event on multiple ranges

    What ranges do tp.A, tp.B etc refer to?
    If posting code please use code tags, see here.

  11. #11
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Re: BeforeDoubleClick worksheet event on multiple ranges

    tp.A: B16-G18
    tp.B: J16-O-18
    ... I named these and then merged them so I can use it like a button and later I can also move them around the spreadsheet without causing problems.
    I have many of these buttons, in the 1600's.

    Thank you TMS, it works and is much better than what I had before.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,378

    Re: BeforeDoubleClick worksheet event on multiple ranges

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Worksheet change event applying to multiple ranges
    By MaddyG in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-29-2013, 12:04 PM
  2. [SOLVED] BeforeDoubleClick Multiple Rows/Ranges
    By ckk403 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-05-2013, 10:34 PM
  3. [SOLVED] BeforeDoubleClick Multiple Ranges
    By ckk403 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-11-2012, 11:16 AM
  4. [SOLVED] Worksheet change event to Formulate Cells for multiple Ranges
    By trickyricky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2012, 02:38 PM
  5. beforedoubleclick event does not trigger
    By anneman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-22-2008, 11:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1