+ Reply to Thread
Results 1 to 7 of 7

Dynamically Generating Links to Run a Macro

  1. #1
    Registered User
    Join Date
    05-12-2012
    Location
    England
    MS-Off Ver
    MS Office 2007 Pro Plus
    Posts
    16

    Dynamically Generating Links to Run a Macro

    Hi,

    I've been racking my brain and can't figure out a solution to what I want to do!

    So I have a worksheet that has results put into it from a database query. This includes the ID of the record. Essentially I want the ID to be a hyperlink or something clickable to the user that will then fire a macro function taking the ID to populate another worksheet with data. I can't figure out how to dynamically create the link which will then fire the UDF. Any ideas?

    Hope this makes sense?

    Thanks
    Gareth

  2. #2
    Forum Contributor
    Join Date
    01-13-2013
    Location
    Oklahoma
    MS-Off Ver
    Office 2007 / Office 2010
    Posts
    123

    Re: Dynamically Generating Links to Run a Macro

    Use text formatting to achieve the look you want and use the Worksheet_SelectionChange sub of the worksheet to run the UDF that you want to run. That's the way I would do it.

  3. #3
    Registered User
    Join Date
    05-12-2012
    Location
    England
    MS-Off Ver
    MS Office 2007 Pro Plus
    Posts
    16

    Re: Dynamically Generating Links to Run a Macro

    Thanks for the response!

    The problem that I've got with that sort of method is that there's no way of guaranteeing the number of records and therefore I can't specify the address / target of the SelectionChange. There's also the potential for 500+ records and creating individual procedures for each isn't really realistic.

  4. #4
    Forum Contributor
    Join Date
    01-13-2013
    Location
    Oklahoma
    MS-Off Ver
    Office 2007 / Office 2010
    Posts
    123

    Re: Dynamically Generating Links to Run a Macro

    The ID is the link. You act on that column, regardless of row. Your UDF looks at the information in the target.row to know what data to pull down next. Write it so it works with everything. If you need help on it, post a sample workbook and I'll see what I can do.

  5. #5
    Registered User
    Join Date
    05-12-2012
    Location
    England
    MS-Off Ver
    MS Office 2007 Pro Plus
    Posts
    16

    Re: Dynamically Generating Links to Run a Macro

    Never thought of that! Thanks very much for your offer. I'll have a crack now and report back!

    Cheers
    Gareth

  6. #6
    Registered User
    Join Date
    05-12-2012
    Location
    England
    MS-Off Ver
    MS Office 2007 Pro Plus
    Posts
    16

    Re: Dynamically Generating Links to Run a Macro

    Thanks for the input! Ended up with this doing the trick:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-13-2013
    Location
    Oklahoma
    MS-Off Ver
    Office 2007 / Office 2010
    Posts
    123

    Re: Dynamically Generating Links to Run a Macro

    Glad it worked out for 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