+ Reply to Thread
Results 1 to 4 of 4

MID Lookup

  1. #1
    Registered User
    Join Date
    08-20-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2011
    Posts
    24

    MID Lookup

    Hello,


    I recently discovered the MID() function thanks to someone on the forum.
    I am using it to decode information from a copy and pasted line to get wind direction and speed.
    The line inputed is:

    METAR CYKZ 081600Z 33013KT 15SM FEW060 BKN260 25/10 A2993 RMK CU1CI3

    And the Formulas below work perfectly to get the wind velocity.

    =MID(V26,FIND("KT",V26)-5,3)
    =MID(V26,FIND("KT",V26)-2,2)

    Now a problem I encountered is sometimes the copy and pasted information, the winds instead of 33013KT are replaced with 32010G17KT when winds are gusting.
    Is there a way to extract the information with =MID(V26,FIND("G##KT",V26)-5,3) and =MID(V26,FIND("G##KT",V26)-2,2) first, and if that does not exist, then to use the previously mentioned formulas?

    Example:
    METAR CYKZ 081500Z 32010G17KT 15SM SCT260 24/10 A2994 RMK CI2 SLP136=

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: MID Lookup

    Try:

    =MID(V26,FIND("KT",V26)-IF(MID(V26,FIND("KT",V26)-3,1)="G",8,5),3)

    and

    =MID(V26,FIND("KT",V26)-IF(MID(V26,FIND("KT",V26)-3,1)="G",5,2),2)

    also if you add +0 to the end of those, it will coerce the result into a real number, instead of a text string that MID() returns
    Last edited by NBVC; 06-08-2012 at 01:26 PM. Reason: added note
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: MID Lookup

    Hi Mattias1,

    Try using below formulas in both the cases:-


    =IFERROR(MID(V26,FIND("KT",V26)-5,3),MID(V26,FIND("KT",V26)-8,3))

    =IFERROR(MID(V26,FIND("KT",V26)-2,2),MID(V26,FIND("KT",V26)-5,2))

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Registered User
    Join Date
    08-20-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2011
    Posts
    24

    Re: MID Lookup

    Thank you NBVC, works perfectly!


    dilipandey, unfortunately this did not give the desired result, it included the term "G" in the string of text.

+ 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