+ Reply to Thread
Results 1 to 12 of 12

Problems with dynamic named range - hyperlinks to trigger macro to change drop down list

  1. #1
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Problems with dynamic named range - hyperlinks to trigger macro to change drop down list

    hi all, good day!

    this is a bit complicated, i'll try to explain as clearly as possible.

    Referring to the attached sample, I have a range across rows and columns, in my sample would be F6:I10.

    Each row in the range represents a hyperlink eg F6:I6 would be hyperlink 1. F7:I7 would be hyperlink 2.... and so on....

    What I wish to do is, when the users click on hyperlink 1 it will trigger the macro where it changes the drop down list according to the numbering of the row, e.g. the first row in my range = F6:I6 would be row 1, thus the drop down would change to 1 when the hyperlink is clicked.

    Currently, I do it in a very long-winded way where I write out all the codes for each range. (refer to attached sample)

    However, in my actual data, I have currently 20 rows and possibly more in the future.
    I have to modify the codes every time I added new rows or columns in my sheet.

    I thought of defining the range by naming the upper left and lower right cells in the range to make it dynamic, but I don't know how to make the rest of the codes working...

    My intended result is hoping to have a macros which is dynamic where I don't have to modify the whole thing should I added rows and columns in the sheet or in the range itself.

    Appreciate any kind assistance.

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    Try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    hi, thank you for your reply!

    I tried the codes given and it worked.

    However, it doesn't work on another sheet(?). I already changed the necessary such as the name of the sheet. It gives me run time 1004: unable to set the listindex property of the drop down class.

    Also, does it work if i have other hyperlinks in the same sheets when the hyperlinks are not within the 'range'?

    Thank you!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    Quote Originally Posted by hcyeap View Post
    hi, thank you for your reply!

    I tried the codes given and it worked.

    However, it doesn't work on another sheet(?). I already changed the necessary such as the name of the sheet. It gives me run time 1004: unable to set the listindex property of the drop down class.

    Also, does it work if i have other hyperlinks in the same sheets when the hyperlinks are not within the 'range'?

    Thank you!
    Is the DropDown on the other sheet also named "Drop Down 1"?
    Does the other sheet's hyperlinks start at row six as well?

    It could be limited to specific hyperlinks within a specific column or rows, or some other criteria. What criteria determines if it's a "desired" hyperlink? Your example workbook didn't illustrate that.
    Last edited by AlphaFrog; 02-04-2014 at 02:17 AM.

  5. #5
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    hi,

    1) i changed the name of the drop down list accordingly
    2) the hyperlinks do not start from row six
    3) basically i have two groups of hyperlinks. the first group only consists of two links and it does not trigger any macros, it only goes to the bottom and the top of the sheets. Second group is the range that i wanted to trigger the macro, they are all grouped together without any empty rows in between.

    what criterias do you mean? the location of the cell?
    Last edited by hcyeap; 02-04-2014 at 02:31 AM.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    Quote Originally Posted by hcyeap View Post
    hi,

    1) i changed the name of the drop down list accordingly
    2) the hyperlinks do not start from row six
    3) basically i have two groups of hyperlinks. the first group only consists of two links and it does not trigger any macros, it only goes to the bottom and the top of the sheets. Second group is the range that i wanted to trigger the macro, they are all grouped together without any empty rows in between.
    1) Did it fix the problem?
    2.) the code i gave takes the hyperlink row and subtracts 5 because the first hyperlink that relates to index1 starts in row six (row 6 - 5 = index 1). If the other sheet's hyperlinks start in a different row, change the -5 value to suit.
    3.) What is the address of the two hyperlinks you want to exclude?

  7. #7
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    hi,

    ok i see the problem now, i didnt change the -5. My current row of first hyperlink in the range is 103, so i changed to 102 and it worked. thanks for pointing out.
    That means I have to change everytime I the range moves? Is there a dynamic way like using named range for the target row something like that?

    my other two hyperlinks that do not trigger any macro are basically link to the bottom which is A123 and link to the top which is A1.

    thanks.

    ps: tried without the two A1 and A123 links'

    ps: tried once again, the two links to A1 and A123 do not affect the macro IF i don't click on them. If i do click on them, it will give error message
    Last edited by hcyeap; 02-04-2014 at 02:47 AM.

  8. #8
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    hi,
    is it possible to use named range and return the row of the range?

    something like
    Please Login or Register  to view this content.
    of course, the above codes are not working....

  9. #9
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    Hi,

    I figured out something like this which is more dynamic.
    The only problem left is to trigger this macro only if the users click the hyperlink in the named range "Table". When users click on other hyperlinks in the same sheet, it wont trigger the macros.

    Appreciate if anyone could help.

    thank you!

    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    hi thanks for your reply...

    it's not working properly.
    yes, when i click on the other two links outside the range, it does not cause error anymore.
    however, instead of changing the "drop down 1", it changes another drop down list. Also, when i click on row 8 and above in the "Table" range, it gives error 1004....

  12. #12
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Problems with dynamic named range - hyperlinks to trigger macro to change drop down li

    hi,

    i change me. to name of sheet...
    Please Login or Register  to view this content.
    and it works flawlessly! (keep my fingers crossed)

    thank you very much for your kind assistance! you really saved me a lot of trouble.
    hopefully i won't have to bother you again with the same question.

    Thank you!
    god bless you.

+ 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. preventing dynamic named range to change when cut/paste to other sheet.
    By darksimoon in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-15-2012, 07:26 AM
  2. Drop down list to trigger a macro
    By HraHuuh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2012, 07:32 AM
  3. Dynamic Named Range List not being updated dynamically
    By scherian in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-09-2012, 04:55 PM
  4. Filling a list box with a dynamic named range
    By Alicita in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-01-2011, 04:12 PM
  5. [SOLVED] Data validation drop downs don't recognize dynamic named range
    By GlenC in forum Excel General
    Replies: 0
    Last Post: 07-19-2006, 01:30 PM

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