Inserting Variables in String

R

Rich

I don't even know if I am using the proper terminolgy but here goes.

I have three columns of variables that I would like to insert in a URL at
specific points. I will try to describe what I am trying to do here in the
following example:

Cell A1 62.987

Cell B1 94.256

Cell C1 Alfrey

Cell D1 http://www.mydomain.com/abcdVarA1efghVarB1hijkVarC1lmn.htm

The above shows only Row 1 of many rows. I would like to insert the contents
of A1 into the URL taking the place of "VarA", insert the contents of cell
B1 into the section that says "VarB" and the contents of cell C1 into the
area VarC.

I would, of course, have different variables in each row. I've done lots of
googling to try to find how to do this but I'm probably using the wrong
terminology as my search criteria.

I'm hoping someone on this list may be able to help me with the solution to
the above problem.

Thanks in advance for any help.

Rich
 
E

Earl Kiosterud

Rich,

It's a bit messy with formulas. This might get you started. It's a macro
that will build your URLs in Column 5.

Sub Links()
Dim Roww As Long
Roww = 1
Do
Cells(Roww, 5) = Replace(Cells(Roww, 4), "VarA1", Cells(Roww, 1))
Cells(Roww, 5) = Replace(Cells(Roww, 5), "VarB1", Cells(Roww, 2))
Cells(Roww, 5) = Replace(Cells(Roww, 5), "VarC1", Cells(Roww, 3))
Roww = Roww + 1
ActiveSheet.Hyperlinks.Add Cells(Roww, 5), Cells(Roww, 5)
Loop While Cells(Roww, 4) <> ""
End Sub
 
Top