+ Reply to Thread
Results 1 to 3 of 3

Thread: Button/Hyperlink/Random Page

  1. #1
    Registered User
    Join Date
    05-08-2011
    Location
    Arkansas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Button/Hyperlink/Random Page

    Ok so I am new here and was browsing the forums. I can usually always find what I need, but I have been messing with this for several hours and its driving me crazy.

    What I want to do is have a button that when clicked will take you to a random page (hyperlink) inside the workbook.

    This is where I am. I made a list of links I wanted to yield by clicking on the button. I used a random number generator to generate a number. Using this number I created an if statement to yield the randomized page as a link in a specified cell. I created a macro to allow the link to be clicked and added it to the button. I thought this would work the way I wanted, but I was wrong. Here is my problem the macro will not pick up on the link that is generated by the if statement. (not saying it won't I don't know how) I tried to fix this by not using if statement and putting a link in the cell and recording the macro. I got the button to work with a link and I got the if statement to yield what I want but I can not combine the two to make it work properly.I am certain I am overlooking something very simple that is why I am asking for help.

    Also if there is another way to just add multiple hyperlinks (randomized) to one button that I do not know about that would be great as well. Thanks in advance for any help that can be offered.
    Attached Files Attached Files
    Last edited by Sman1985; 05-08-2011 at 09:43 AM. Reason: Added a dummy workbook just so you could get an idea of what I am doing.

  2. #2
    Forum Guru mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    2,997

    Re: Button/Hyperlink/Random Page

    Maybe some code like this?

    Sub RandomHyperlink()
    ActiveSheet.Hyperlinks(WorksheetFunction.RandBetween(1, ActiveSheet.Hyperlinks.Count)).Follow
    End Sub
    Martin

    Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.

    If my solution has saved you time and/or money, please consider donating to Cancer Research UK.

  3. #3
    Registered User
    Join Date
    05-08-2011
    Location
    Arkansas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Button/Hyperlink/Random Page

    Sweet that was exactly what I was looking for. Is there a way to set it to only random between certain hyperlinks in certain cells so if I put more than one hyperlink it will only use the ones selected?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0