+ Reply to Thread
Results 1 to 6 of 6

Importing selective external data from a webpage

  1. #1
    Registered User
    Join Date
    11-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Importing selective external data from a webpage

    Hi there, when importing a new web query how can i be more selective in the data i import?

    Last Trade: 1,521.30 p
    Trade Time: 9:53am
    Change: Up 28.30 (1.90%)
    Prev Close: 1,493.00
    Open: 1,503.00
    Bid:1,521.00
    Ask:1,522.00
    1y Target Est:1,442.50 p

    Above is the minimum data that the web query allows me to import, however most of this is useless to me. I've imported this data on to a separate sheet within my workbook, and then inturn use this raw data as a reference to my main spreadsheet. The only bit of information i need is taken from cell B1 '1,521.30 p' however because this cell contains the letter p it doesn't allow the formulas to calculate on my main spreadsheet. Is there any way i can lose the p so when i update my spreadsheet it only uses the numerical value in that cell and ignores any lettering? I'm sure there must be a simple way around this, but i'm really struggling so will appreciate any help. Thanks

    WTB
    Last edited by WTB; 11-11-2009 at 07:05 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Importing selective external data from a webpage

    How about this: wherever you use a reference to B1, instead use

    (SUBSTITUTE(B1," p","")*1)

    So, if you had a formula like

    =B1+A5

    use this instead:

    =(SUBSTITUTE(B1," p","")*1)+A5

    The Substitute part will replace the space and p with nothing, and the multiplication with 1 coerces the remaining text string into a number.

    Alternatively, with double unary, avoiding a multiplication calculation and saving processing time:

    =--(SUBSTITUTE(B1," p",""))+A5

    hth
    Last edited by teylyn; 11-11-2009 at 06:39 AM.

  3. #3
    Registered User
    Join Date
    11-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Importing selective external data from a webpage

    That's brilliant, problem solved thank you

    WTB

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Importing selective external data from a webpage

    Quote Originally Posted by teylyn
    Alternatively, with double unary, avoiding a multiplication calculation and saving processing time:

    =--(SUBSTITUTE(B1," p",""))+A5
    FWIW: the explicit coercion by means of addition negates need for double unary in first instance, ie:

    =SUBSTITUTE(B1," p","")+A5

    will do the same thing with one less operation
    Last edited by DonkeyOte; 11-11-2009 at 07:40 AM. Reason: typo

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Importing selective external data from a webpage

    FWIW: the explicit coercion by means of addition negates need for double unary in first instance, ie:
    True, but if you have the output in a cell of its own without any calculation, you need the coercion to make the value available to calls from other cells.

    A1 =--(SUBSTITUTE(B1," p",""))

    needs the coercion so C1 can do SUM or whatever on A1

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Importing selective external data from a webpage

    Not denying that but then that was not the point I was making... and that was not the purpose of your formula on which my comment was based

+ 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