+ Reply to Thread
Results 1 to 26 of 26

Hyperlink Syntax Issue

Hybrid View

sgrande01 Hyperlink Syntax Issue 07-10-2013, 01:48 PM
Lifesigns Re: Hyperlink Syntax Issue 07-10-2013, 01:54 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 02:01 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 02:04 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 02:09 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 02:12 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 02:25 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 03:42 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 03:37 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 03:45 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:01 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:10 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:32 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:25 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 04:37 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 04:33 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:35 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 04:37 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:40 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 04:46 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:49 PM
ussenterprise Re: Hyperlink Syntax Issue 07-10-2013, 04:58 PM
sgrande01 Re: Hyperlink Syntax Issue 07-10-2013, 05:27 PM
  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Hyperlink Syntax Issue

    All,

    I've been trying for a very long time to get a dynamic hyperlinking formula in vba to work correctly. I was having issues with the simple =Hyperlink() function but found a solution to have the formula work correctly. i have some ranges i need to use within the formula but i can't get the syntax. i've been working on and off on this for 3 days with no success. can anyone take a look:

    For Each NewCell3 In CCTOCList
            Range("I" & currentRow2) = "=HYPERLINK(" & """#'""" & Range("O" & currentRow2).Value & "'!BK9,""" & Range("O" & currentRow2).Value & """)"
            currentRow2 = currentRow2 + 1
    Next NewCell3
    what i would like to appear in excel:

    =HYPERLINK("#'OPRATIONS1'!BK9","OPRATIONS1")

    the range 06 would be "OPRATIONS1", the name of the tab.

    Thank you

    edit: i am getting an "Application-defined or object defined error" message.

  2. #2
    Forum Contributor
    Join Date
    11-25-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    120

    Re: Hyperlink Syntax Issue

    Hey welcome to the forum and thanks for using the code blocks.

    Do you have a sample file we could take a look at?
    If the post was helpful please click the black star on the bottom left to add some reputation and mark your thread as SOLVED.

    A day with nothing new achieved or learned, albeit however small, is a day lost forever?

    Constant Never Ending Improvement

  3. #3
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    i'm sorry - neither IE or chrome will allow me to open the attachment window.

  4. #4
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    You may have popups blocked. Can these be unblocked?
    Rep is appreciated. Click my * if I helped.

  5. #5
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    the pop-up is appearing but there is nothing within the window.

    i can email the file?

  6. #6
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Unfortunately, I cannot accept emails. A few other users here may be able to assist though with a link to something like a dropbox...

    [edit] And its rather odd that there is nothing in the popup!

  7. #7
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    any way you think you can try without having the file?

  8. #8
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Hm. Can't get the MsgBox to run. It might be due to not having all the information. Still working it out...

  9. #9
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    I'll give it a go:
    Range("I" & currentRow2) = "=HYPERLINK" & ("""#'""" & Range("O" & currentRow2).Value & """'!BK9,""" & Range("O" & currentRow2).Value)"
    This somewhat similar to what I am doing. I moved the first '&' outside of the parentheses. Moved around some quotes.
    One thing you could try is:
     
    MsgBox (Range("I" & currentRow2) = "=HYPERLINK" & ("""#'""" & Range("O" & currentRow2).Value & """'!BK9,""" & Range("O" & currentRow2).Value)")
    or
    MsgBox ("I" & currentRow2) = "=HYPERLINK" & ("""#'""" & Range("O" & currentRow2).Value & """'!BK9,""" & Range("O" & currentRow2).Value)"
    This will help in troubleshooting...
    Last edited by ussenterprise; 07-10-2013 at 03:38 PM. Reason: Stuck 'o' key... lol

  10. #10
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    I am getting a Method 'Range' of object '_Global' failed (1004 error)...

  11. #11
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Can you paste the whole macro in?

  12. #12
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    I ran this:
    Sub MsgBoxTest()
    MsgBox ("I" & currentRow2)
    End Sub
    I am only returning an 'I' in the box. What is currentRow2? I suspect this is a Dim, but want to be sure...

  13. #13
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    MsgBox "=HYPERLINK("
    works normally.
    MsgBox "=HYPERLINK(" & "#'"
    works normally (Removed triple quotes here...)
    MsgBox "=HYPERLINK(" & "#'" & "'!BK9,"
    works normally (removed triple quotes again...)
    MsgBox "=HYPERLINK(" & "#'" & "'!BK9," & ")"
    works normally. I added the & at the end.

    Try this:
    Range("I" & currentRow2) = "=HYPERLINK(" & ("#'" & Range("O" & currentRow2).Value & "'!BK9," & Range("O" & currentRow2).Value) & ")"
    Last edited by ussenterprise; 07-10-2013 at 04:36 PM. Reason: Let out one tiny character...

  14. #14
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    If I MsgBox this:
    MsgBox "=HYPERLINK(" & """#'""" & Range("O" & currentRow2).Value & "'!BK9,""" & Range("O" & currentRow2).Value & """)"
    I get the Range of object failed.

    I removed both ranges and reattempted:
    MsgBox "=HYPERLINK(" & """#'""" & "'!BK9,")"
    I get expected: end of statement.

    It looks like it doesn't like the '(' to be inside the quote...

    Still looking...

  15. #15
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    i'm starting to think this simply won't work in VB.

    just as a reminder, it has to be in this format:

    =HYPERLINK("#'OPRATIONS1'!BK9","OPRATIONS1")

  16. #16
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    sorry for the delayed response - in some meetings.

    i've went through it so, so slowly and continue to get an end of statement or application defind or object defined error. here is the entire code:

    also, this DID work, meaning it pasted into excel, however, the hyperlink code itself does not function. it needs the #.

    For Each NewCell3 In CCTOCList
            Range("I" & currentRow2) = "=hyperlink(" & Range("O" & currentRow2).Value & "!BK9,""" & Range("O" & currentRow2).Value & """)"
            currentRow2 = currentRow2 + 1
    Next NewCell3


    Sub RunHyperLinks()
    
    Dim ws As Worksheet
    Dim NewCell2 As Range
    Dim arC
    Dim Lastrow As Integer
    Dim ARC2 As Range
    Dim CurrentRow As Integer
    Dim NewCell3 As Range
    Dim CCTOCList As Range
    Dim currentRow2 As Integer
    Dim AddressR As Range
    
    
    Set ws = Sheets("Key")
    arC = ws.Range("i2").Value
    Range(arC).Copy
    
    
    Sheets("Control Page").Range("I6").PasteSpecial Paste:=xlPasteValues
    Sheets("Control Page").Activate
    
    Lastrow = Range("I65536").End(xlUp).Row
    Set ARC2 = Range("J6:J" & Lastrow)
    CurrentRow = 6
    
    For Each NewCell2 In ARC2
        Range("J" & CurrentRow).Value = "=VLOOKUP(I" & CurrentRow & ",CCLIST,2,FALSE)"
        CurrentRow = CurrentRow + 1
    Next NewCell2
            
    Set CCTOCList = Range("i6:i" & Lastrow)
    
    currentRow2 = 6
    
    Range("I6:I" & Lastrow).Copy
    Range("o6").Select
    Sheets("Control Page").Range("o6").PasteSpecial Paste:=xlPasteValues
    
    
    For Each NewCell3 In CCTOCList
            Range("I" & currentRow2) = "=HYPERLINK(" & """#'""" & Range("O" & currentRow2).Value & "'!BK9,""" & Range("O" & currentRow2).Value & """)"
            currentRow2 = currentRow2 + 1
    Next NewCell3
    
    
    Range("O6:O" & Lastrow).Delete
    Range("A1").Select
    
    
    End Sub

  17. #17
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    See my post above. I think that'll get it for you.

  18. #18
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    still getting the application defined error...

  19. #19
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Let me take another look.

  20. #20
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    maybe let's try to simplify it by taking the ranges out and just making the cells static. once the code will go into excel correctly then maybe move the dynamic ranges in?

  21. #21
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Quote Originally Posted by sgrande01 View Post
    maybe let's try to simplify it by taking the ranges out and just making the cells static. once the code will go into excel correctly then maybe move the dynamic ranges in?
    Hm. One sec...

  22. #22
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Hm... strangeness on this one.
    I'll have to continue tomorrow.

  23. #23
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Hyperlink Syntax Issue

    Sub test()
    MsgBox "=HYPERLINK(" & ("#'" & "OPRATIONS1" & "'!BK9," & "OPRATIONS1" & ")")
    End Sub
    This appears to work as intented. At least in the MsgBox.
    And... I see what you mean. I have an idea, but it may take me a while to research it...

  24. #24
    Registered User
    Join Date
    09-21-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hyperlink Syntax Issue

    i got it:

    Range("I" & currentRow2) = "=HYPERLINK(""#" & Range("O" & currentRow2).Value & "!BK9"",""" & Range("O" & currentRow2).Value & """)"
    thanks for the help!

+ 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