+ Reply to Thread
Results 1 to 6 of 6

Convert Number to Text (to enable vlookup)

  1. #1
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    Convert Number to Text (to enable vlookup)

    Good morning,


    I would like to make a macro to turn selected data from number to text.

    Basically I have two sheets, one is data imported from a database that has a reference stored as text. The other is a sheet with that reference number on it, but stored as a number.

    This reference is for the most part alpha numeric, but there is a small percentage that are just numeric stored as text - there is no fixed character length to these and no number begins with 0.

    When I lookup from one sheet to the other I get a n/a, in order for it to read I have to change the format to text and hit f2, enter, f2, enter.......

    This isn't a problem when I look at the report on a weekly basis as there is 20-30, but I need to look at the last 3 years and there is thousands.

    I am looking for something to either automate the F2, Enter for a range of cells or maybe you know of a more efficient way to do this.

    Any help would be greatly appreciated.


    Kenny

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Convert Number to Text (to enable vlookup)

    Hi Kenny,

    try this
    Please Login or Register  to view this content.
    Please click the * below if this helps
    Please click the * below if this helps

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Convert Number to Text (to enable vlookup)

    convert numbers with TEXT function
    If solved remember to mark Thread as solved

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,935

    Re: Convert Number to Text (to enable vlookup)

    If your formula is:

    =VLOOKUP(A2, Sheet1!A:B,2,FALSE)

    try:

    =VLOOKUP(A2&"", Sheet1!A:B,2,FALSE)


    or, real belt and braces:

    =IFERROR(VLOOKUP(A2,$F$2:$G$8,2,FALSE),IFERROR(VLOOKUP(A2&"",$F$2:$G$8,2,FALSE),""))


    So, that tries the value as is; if there is an error, it tries it converted to text; and, if it still fails you get a blank. You could convert that to an error message.


    Regards, TMS





    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Convert Number to Text (to enable vlookup)

    Cheers TMShucks, works perfectly.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,935

    Re: Convert Number to Text (to enable vlookup)

    You're welcome. Thanks for the rep.

+ 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