VB: inserting text into a cell (excel 03)

J

Jabberwocky

the following snippet of code does not work becaus the equal sign
within the quotes creates an error.
If i precede the equal sign with an apostrophe, the apostrophe is
inserted into the cell, causinng the formula to be interpreted as
text..

Sheets("Caseload").Range(sel$).Value = "=Hyperlink(http://
www.dc.state.fl.us/InmateReleases/list.asp?DataAction=Filter&dcnumber="
& Range("L3").Value & "," &
Application.WorksheetFunction.Proper(Range("b3").Value) & ")"

Is there a more elegant way of pasting a value, and making it a
hyperlink? I don't really need to have a formula in the cell if the
VB script can create the hyperlink.

Pardon my poor terminology (self-taught)

--Todd
 
D

Dave Peterson

It's not the equal sign that's causing the trouble. You're missing the double
quotes that surround the link address.

The formula would look like:
=hyperlink("http://www.microsoft.com")

So

Sheets("Caseload").Range(sel$).Formula = "=Hyperlink(""http://" _
& "www.dc.state.fl.us/InmateReleases/list.asp?DataAction=Filter&dcnumber=" _
& Range("L3").Value & "," _
& Application.WorksheetFunction.Proper(Range("b3").Value) & """)"

ps. I changed the .value to .formula since it's a formula.

pps. When you need a double quote in a string, you have to double them up in
your code.
 
J

Jabberwocky

Thanks. That did the trick. Do you know a way to make it a
hyperlinked text rather than a formula?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top