+ Reply to Thread
Results 1 to 4 of 4

converting constant/text to formula and evaluate it

  1. #1
    Registered User
    Join Date
    02-18-2005
    Location
    SF
    Posts
    2

    Question converting constant/text to formula and evaluate it

    Hi, it's my first post here, i did a quick search on the forum but couldn't find what i was looking for, so hope someone can offer advice to the following problem:

    1. I'm importing data into excel using a db query. One of the columns returned is a string that, if evaluated as a formula in Excel, would produce a cell with a hyperlink, i.e:

    =HYPERLINK("http://www.yahoo.com", "Yahoo Website")

    2. The problem is that when i import the data, Excel shows the above exactly as is and doesn't treat it as a formula. This is fairly logical as Excel shouldn't know that that is what i want. So my question is, how do I program Excel now to look at this column, convert it from a constant to a formula, and then evaluate so it becomes just (actively linked):

    Yahoo Website

    and thus allows me to click on that cell to get to the link.

    3. If I went into the cell individually and pressed enter at the end of the string (in step 1), Excel then treats it as a formula and I get the result I want. However, I have hundreds of rows and would like to evaluate the entire column in one shot.

    Anyone have ideas on how to do this? Thanks a lot!!!

    paul

  2. #2
    Tom Ogilvy
    Guest

    Re: converting constant/text to formula and evaluate it

    This will do it. Assume column B:

    Sub ReevaluateColumnB()
    Columns(2).Replace _
    What:="=", _
    Replacement:="=", _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    MatchCase:=False
    End Sub

    change the 2 to reflect the column to be processed.

    --
    Regards,
    Tom Ogilvy





    "tsuoying" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi, it's my first post here, i did a quick search on the forum but
    > couldn't find what i was looking for, so hope someone can offer advice
    > to the following problem:
    >
    > 1. I'm importing data into excel using a db query. One of the columns
    > returned is a string that, if evaluated as a formula in Excel, would
    > produce a cell with a hyperlink, i.e:
    >
    > =HYPERLINK("http://www.yahoo.com", "Yahoo Website")
    >
    > 2. The problem is that when i import the data, Excel shows the above
    > exactly as is and doesn't treat it as a formula. This is fairly
    > logical as Excel shouldn't know that that is what i want. So my
    > question is, how do I program Excel now to look at this column, convert
    > it from a constant to a formula, and then evaluate so it becomes just
    > (actively linked):
    >
    > Yahoo Website
    >
    > and thus allows me to click on that cell to get to the link.
    >
    > 3. If I went into the cell individually and pressed enter at the end
    > of the string (in step 1), Excel then treats it as a formula and I get
    > the result I want. However, I have hundreds of rows and would like to
    > evaluate the entire column in one shot.
    >
    > Anyone have ideas on how to do this? Thanks a lot!!!
    >
    > paul
    >
    >
    > --
    > tsuoying
    > ------------------------------------------------------------------------
    > tsuoying's Profile:

    http://www.excelforum.com/member.php...o&userid=20110
    > View this thread: http://www.excelforum.com/showthread...hreadid=346810
    >




  3. #3
    Registered User
    Join Date
    02-18-2005
    Location
    SF
    Posts
    2

    Thank you!

    Tom, thank you for that script, it works perfectly!

    Another question.... is it possible to make the result look like a link, instead of just text? After I run the function, the cell contents are still black, not the 'expected' blue. It's still a link but could be made more intuitive by changing its color. Any way to do that? Thanks again!

    paul

  4. #4
    Tom Ogilvy
    Guest

    Re: converting constant/text to formula and evaluate it

    Sub ReevaluateColumnB()
    Columns(2).Replace _
    What:="=", _
    Replacement:="=", _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    MatchCase:=False
    Columns(2).specialCells(xlFormulas).Font.ColorIndex = 5
    End Sub

    --
    Regards,
    Tom Ogilvy


    "tsuoying" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Tom, thank you for that script, it works perfectly!
    >
    > Another question.... is it possible to make the result look like a
    > link, instead of just text? After I run the function, the cell
    > contents are still black, not the 'expected' blue. It's still a link
    > but could be made more intuitive by changing its color. Any way to do
    > that? Thanks again!
    >
    > paul
    >
    >
    > --
    > tsuoying
    > ------------------------------------------------------------------------
    > tsuoying's Profile:

    http://www.excelforum.com/member.php...o&userid=20110
    > View this thread: http://www.excelforum.com/showthread...hreadid=346810
    >




+ 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