+ Reply to Thread
Results 1 to 12 of 12

Use a command button to activate a hyperlink

  1. #1
    Forum Contributor
    Join Date
    04-11-2008
    Posts
    156

    Use a command button to activate a hyperlink

    Hi,

    I am completely new to VBA and writing macros.

    I am trying to write a macro that activates the following funtion in cell D1.

    =HYPERLINK("#"&C2,"")

    I have recorded the following macro but it only jumps to the cell the function is in rather than actually activating the function and jumping to reference which has been selected in C2.

    Thanks for your help.

    Please Login or Register  to view this content.

  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
    Hello penfold,

    Here is the VBA code...
    Please Login or Register  to view this content.
    If I remember correctly, hyperlinks created by the formula method aren't accessible through VBA code.

    Sincerly,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    04-11-2008
    Posts
    156
    Thank you.

    I can't get this to work, even with a standard hyperlink.

    Is this all the code that is required or should I be adding it to other code?

    Please can you give me the full code from begining to end.

    I'm grateful for your help.

    Thanks

  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
    Hello penfold,

    The code I posted assumes the hyperlink to be on the ActiveSheet. If it is not then you should qualify the reference with the worksheet name, like this...
    Please Login or Register  to view this content.
    This code works if the hyperlink was added to the cell using VBA code or you inserted it using the context menu. If you still have problems, it would be best for to post your workbook for review.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    04-11-2008
    Posts
    156
    Hi Leith,

    Sorry, I can't seem to win.

    I have posted the workbook.

    Thanks for your help.
    Attached Files Attached Files

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

    I am having a problem downloading your file. The forum is sluggish right now, so that may be the problem. I will keep trying. If I can't download the file, you can email me at [email protected]. I can then review it and repost it for you.

    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor
    Join Date
    04-11-2008
    Posts
    156
    Emailed as per you reply.

    Many thanks

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

    I promised to post with a solution. Here is the macro used to select and display the client list. Hyperlinks weren't needed since all the elements of the list were named ranges. These names appear in a ListBox that user can select from. When the user clicks the command button the entry is then scrolled into view. The attached workbook has the macro installed.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    04-11-2008
    Posts
    156
    Leith,

    Curently the list box input range is in the same worksheet.

    When I move the input range to a separate worksheet the macro stops working.

    I have tried to qualify the reference without success.

    Can I ask for your help yet again?

    Thanks

  10. #10
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867
    Please familiarise yourself with the rules before posting. You can find them here.

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

    I removed the command button, and attached the macro to the List Box. Now when the user clicks a client, the information is displayed immediately. The client names are on Sheet2 in cells A1, and A2. Let me know if you have any problems. Here is the updated macro, which has already been installed.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files
    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!)

  12. #12
    Forum Contributor
    Join Date
    04-11-2008
    Posts
    156
    Excellent, thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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