Consulting

Results 1 to 4 of 4

Thread: Activating Hyperlinks

  1. #1
    VBAX Newbie
    Joined
    Aug 2010
    Posts
    3
    Location

    Activating Hyperlinks

    Hello everyone

    I have a workbook with 2 sheets "input" and "links". The "links" sheet is a table of material codes, descriptions, suppliers, and a hyperlink to specification sheets for each material/supplier.

    The user will enter a material code in A1 of the "input" sheet, vlookups will fill Cells B2:E21 with details of all the entries that match the code, i.e column B (code), Column C (material description) ,Column D (supplier), and column E (the row number of the links sheet that contains the hyperlink).

    I would like a code so the once the user has entered a material code which, for example, returns 4 entries and selects the entire row containing the entry of interest and the marco will active the correct hyperlink in column G row ??? of the "links" sheet.

    Being new to vba I cant record the macro because of the variable. I have looked on this and other sites for a clue of how to do it and I am either looking in the wrong places or not understanding what I see because what ever I have tried doesn't work.

    Thanks in advance

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    What have you tried? Also can you post a sample workbook. Welcome aboard, enjoy the ride!!!
    Peace of mind is found in some of the strangest places.

  3. #3
    VBAX Newbie
    Joined
    Aug 2010
    Posts
    3
    Location

    Activating Hyperlinks

    Hi austenr

    Thanks for your response.

    I have attached a sample file to look at.

    You will see that in A1 of the input sheet is 100001 and that displays 19 lines of white pepper from 19 suppliers. If the user wants to see the specification sheet from supplier M, I want them to select the row by clicking on the row number and this would active the hyperlink that is in E16 of the links sheet. (Spec is the friendly name for all the hyperlinks)


    I have tried recording the task but I have to manualy select the correct link. As I don't know much about VBA I dont know how to tell it the correct row of the links sheet. When the sheet is complete there will be 1100-1200 entries in total each with its own hyperlink.

    Thanks

    colh99

  4. #4
    VBAX Newbie
    Joined
    Aug 2010
    Posts
    3
    Location

    activating hyperlinks

    I have this code that does what I want

    Sub runlink()
    '
    'runlink
    '
    'Dim requiredrow As String

    Application.ScreenUpdating = False
    requiredrow = ActiveCell.Formula
    Sheets("LINKS").Visible = True
    Sheets("LINKS").Select
    Range("E" & requiredrow).Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    Sheets("LINKS").Visible = False
    Application.ScreenUpdating = True

    End Sub

    I have 3 questions
    1. How do I post Code properly?

    2. Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    what does AddHistory do?

    3. how can I avoid a runtime error when the link doesn't work for example when the linked file has been removed but the hyperlink cell entry has not?

    Thanks

Posting Permissions

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