+ Reply to Thread
Results 1 to 4 of 4

VBA convert number stored as text to number

  1. #1
    Registered User
    Join Date
    01-08-2015
    Location
    Australia
    MS-Off Ver
    Mac 2011
    Posts
    75

    VBA convert number stored as text to number

    Hi,

    I am creating a spreadsheet for others to use. In the past I have found that when others paste data into the spreadsheet sometimes the data is stored as text which means that the formulas won't calculate correctly. They may also have leading or trailing spaces. I have used the following to fix the leading/trailing spaces and it seems to work. I can't figure out how to also convert these columns in the same macro so that the formulas work correctly. You will see in my example that row 7 is correctly calculated but row 8 is not. I have used 'define name' as these columns will change when columns are inserted/deleted by the users. The range is columns D,E,M & S. My knowledge of macros isn't the best, I really just play around with suggestions I find on forums like this but I can't seem to get this one.

    Any help would be greatly appreciated.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA convert number stored as text to number

    Try
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-08-2015
    Location
    Australia
    MS-Off Ver
    Mac 2011
    Posts
    75

    Re: VBA convert number stored as text to number

    Thanks Jindon, that seems to work. If I want this to run with the macro above when a button is pressed do I need to call your macro within the first macro or is there another way?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA convert number stored as text to number

    Well I'd call the code when the data has been added to the sheet, it depends on you...

+ 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] Text stored as number when copied from one sheet to another, Auto convert required
    By A440 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2016, 09:06 AM
  2. Macro - Convert stored text to number
    By adste89 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-19-2013, 09:19 AM
  3. [SOLVED] Set a Value as Number (Number Stored as Text warning comes up)
    By OberonViking in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2013, 01:41 AM
  4. Replies: 1
    Last Post: 10-28-2012, 05:42 AM
  5. Convert Excel cells stored as text to date and number coming from notepad
    By Fire_d in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-31-2010, 12:34 AM
  6. [SOLVED] how do i convert a number stored as text to a numb in a vba loop
    By bobm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2010, 05:06 AM
  7. Number stored as text. How do I keep the number format?
    By staying in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-13-2006, 11:57 PM

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