Consulting

Results 1 to 9 of 9

Thread: Solved: Selecting a hyperlink using Data Validation

  1. #1
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location

    Solved: Selecting a hyperlink using Data Validation

    I have a Data Validation Field on Sheet2 Cell C3 that uses a list from Sheet1 Cells A2-A11 as its input.

    Each Cell on Sheet1, that makes up the Data Validation List, also has their own individual Hyperlink (10 different hyperlinks).

    Is there a way to open the appropriate hyperlink when the user makes their selection on Sheet2 C3 using the Data Validation List?

    Thanks for any help...

    JimS

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Use a selection change event on the DV cell, and get the list value link by matching the selected DV Value against the list, and do a Follow Hyperlik on the matched cell hyperlink value.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    Sounds good, how do I "get the list value link by matching the selected DV Value against the list, and do a Follow Hyperlik on the matched cell hyperlink value"?

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try this

    [VBA]
    'Sheet module
    Private Sub Worksheet_Change(ByVal target As Range)
    DoFollow target
    End Sub

    'Standard module
    Sub DoFollow(target As Range)
    ActiveWorkbook.FollowHyperlink Range("Data").Find(target.Value).Hyperlinks.Item(1).Address
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    mdmackillop,

    Thanks - This is what I'm after "but" (always a but), I would like to call the routine from another Macro, not a Change Event.

    I can't figure out the syntax so that it will work when called from another macro.

    Can it be modified to work?

    Thanks again...

    JimS

  6. #6
    VBAX Regular
    Joined
    Oct 2009
    Location
    Fremont, CA
    Posts
    72
    Location

    Try this

    I won't claim that I fully understand why you would want to do that, but, assuming that the DoFollow routine proposed by mdmackillop works for you, you should be able to call it from another macro simply by using the following statement:

    DoFollow {range}

    where {range} is intended to denote the cell (i.e. range) you would like to pass along to the DoFollow routine, just like mdmackillop did in the Worksheet_Change routine he proposed.

    Hope this helped,
    Rolf

  7. #7
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    Still won't work.

    Can it be set up so that a CommandButton1_Click will run the DoFollow code instead of the Worksheet_Change?

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Yes

    [VBA]
    DoFollow ActiveCell
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    VBAX Mentor
    Joined
    Jan 2009
    Posts
    304
    Location
    That's what I needed.

    Thank you both...

Posting Permissions

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