A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
hi, if i understand the problem well enough / not sure if this is the problem:
i currently have a script that splits hyperlinks so can follow the hyperlink thru vb.
it seems that is not enough if want to manipulate the hyperlink as well
which to say: want to put the hyperlink itself into code so can disect the web address & make different variations of the destination occur.
what trying to use is a udf for: =CLINK("friendly name") so the vb for calling a split hyperlink will not work.
the code for following a hyperlink by vb i have is:
goFHL ActiveCell.Formula, ",friendlyname"
that runs the macro: (which will split off the friendly name: ",IF(P612>0" etc, in the next example below.
Sub goFHL(strF As String, strDL As String)
so by vb to run the hyperlink in a worksheet:
=HYPERLINK($BM$4&BH9,IF(P612>0,"O","F"))
i would use this vb:
goFHL ActiveCell.Formula, ",IF(P"
==========
The question would then seem to be how to follow a hyperlink that has been put together by vb, for example used is a custom hyperlink being called like: function CLINK(strFriendlyname)
by the instructions for that code, a logical? / in document? / hyperlink exists in the cell by right click cell, hyperlink, (and per a NON-requirement: select any hyperlink) - where the code will run any link item variables supplied.
QUESTION:
this method allows a click on the cell to follow the hyperlink. i am not sure / how to write code to inititate follow the hyperlink.. thru code.
Call CLINK 'does not seem to work
if haven't said, the code i have for following a custom hyperlink will allow me to make changes in any portions for eg: LINK1 LINK2 etc below:
link1 being: "http://www.google.com/search?q="
link2 being: Cells(ActiveCell.row, B5).Value '(i have these already working in my workbook)
'HOW DO I CALL THIS MACRO.. TO RUN IN ANOTHER VB? thanks:
Call CLINK 'does not seem to work
Function CLINK(strFriendlyText As String) As Variant 'i have this macro working
'Function CustomHyperlink(Term As String) As String 'orig
Dim B5 As String 'workcell shows: BH:BH
B5 = RANGE("B5")
Dim rng As RANGE
Set rng = Application.Caller
CustomHyperlink = strFriendlyText
'CustomHyperlink = Term
If rng.HYPERLINKS.Count > 0 Then
rng.HYPERLINKS(1).Address = "http://www.google.com/search?q=" & Cells(ActiveCell.row, B5).Value '<< my modification
'rng.HYPERLINKS(1).Address = "http://www.google.com/search?q=" & Term 'orig
End If
End Function
'instructions for the above: 1. call as: =CLINK("friendly name") original: =CustomHyperlink(A1)
'2. create hyperlink in cell: rc, hyperlink (pick any hyperlink valid or invalid)
'3. put friendly name in cell eg: "T" or: =CustomHyperlink(Left(H9,1))
'4. if result has some cell attached to end of hyperlink, rclick, hyperlink & remove eg: #A1 at end of link, before you paste it down a column
'old: 3. put required search term in formula eg: A1
'==========
if anyone needs the example i was given for calling a normal hyperlink, it is:
Sub goFHL(strF As String, strDL As String) 'GOFHLXXX gofhlxxx 255 chars AS: goFHL ActiveCell.Formula, ",friendlyname"
Dim V As Variant
If InStr(1, strF, "HYPERLINK") = 0 Or InStr(1, strF, strDL) = 0 Then
Application.EnableEvents = True 'EVENTS
Exit Sub
End If
V = split(strF, strDL)
On Error Resume Next
ActiveWorkbook.FollowHyperlink Application.Evaluate(Replace(V(0), "HYPERLINK(", ""))
'HYPERLINK (left of friendly name: ",eg comma anyname")
Application.EnableEvents = True 'EVENTS
End Sub