+ Reply to Thread
Results 1 to 8 of 8

Macro doesn't record formating "general" text into number

  1. #1
    Registered User
    Join Date
    06-11-2014
    Posts
    12

    Macro doesn't record formating "general" text into number

    Hi,

    I need a macro that will sort out a report for me. The report is dowloaded from our internal system and it needs to be sorted by ISBN number.
    The ISBN are shown as numbers
    e.g. 9780194070027
    but there is a little green triangle in the top left hand corner of the cell and if you put the mouse cursor over it then a little box with a rhombus and an exlamation mark pops up. When you click on it, the message is "Number stored as Text" and you get the option to "Convert to Number." After choosing this option ISBN lookslike this:
    9.78019E+12
    So I then need to go into the formaling tools and choose "Number" and then also get rid of the decimal places.

    I have tried to record those steps in a macro but nothing happens. Is there a way to record it so that it works properly?
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Macro doesn't record formating "general" text into number

    range("a1").numberformat="0"
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro doesn't record formating "general" text into number

    You can tell Excel to treat numbers stored as text as numeric when sorting.

    When you try and sort your ISBN numbers a dialog with the option should pop-up.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-11-2014
    Posts
    12

    Re: Macro doesn't record formating "general" text into number

    Thanks.
    The problem is that I need those ISBNs to be numbers because in the previous worksheet I have vlookup functions set up and without changing the ISBNs into numbers the vlookups don't work...
    This is the macro code I have at the moment:
    Columns("B:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:H").Select
    Selection.Delete Shift:=xlToLeft
    Columns("B:B").Select
    Selection.Cut
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.NumberFormat = "0"

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro doesn't record formating "general" text into number

    You can use VALUE in the VLOOKUPs to convert the ISBN as text to numeric.

  6. #6
    Registered User
    Join Date
    06-11-2014
    Posts
    12

    Re: Macro doesn't record formating "general" text into number

    I'm sorry, I am not very good at excel, how would I create a vlookup function using VALUE?

    At the moment, I have my first worksheet with a list of ISBNs (formated as numbers) in column A. The second worksheet has the dowloaded report with ISBNs that are not formated and a lot of other information which I have to pull through to the first worksheet. So, for example, to look up a price for specific ISBN my formula on the forst workseet is:
    =VLOOKUP(A3,Invoice,4,FALSE)

    Where do I stick the VALUE function?

    Thank you!

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro doesn't record formating "general" text into number

    If A3 has an ISBN stored as text and you want to look it up in Invoice where the ISBNs are numeric this is how you would use VALUE.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-11-2014
    Posts
    12

    Re: Macro doesn't record formating "general" text into number

    !!! Got it !!!

    Thank you Norie!

    In my macro I have changed the ISBNs using the VALUE function and then copied and pasted as "special." It works!

    Thank so much for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. Replies: 0
    Last Post: 08-22-2012, 03:40 PM
  3. [SOLVED] Set default data format to "text" instead of "general"
    By Delta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-04-2012, 02:44 PM
  4. [SOLVED] Re: macro for converting number stored as "text" (or preceeded with ') to "number" formatting
    By markx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2006, 07:14 AM
  5. [SOLVED] macro for converting number stored as "text" (or preceeded with ') to "number" formatting
    By markx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2006, 10:20 AM

Tags for this Thread

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