+ Reply to Thread
Results 1 to 8 of 8

VBA code for text to number

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    Nova Scotia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Red face VBA code for text to number

    Hello all
    I'm currently working on an excising excel document, which we use to keep track of client progress, i would like it to change so anytime someone inputs "na" into a cell to would convert it to a 4 within a certain range, so when we use it in several formulas it would calculate appropriately, does anyone know how i can do this?

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: VBA code for text to number

    Place this into the worksheet module of the sheet you want to prevent na

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    Nova Scotia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA code for text to number

    Thanks Mike that worked perfectly

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA code for text to number

    @ Mellie_d1

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  5. #5
    Registered User
    Join Date
    08-07-2012
    Location
    Nova Scotia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA code for text to number

    ok so now that i have that fix, i was wondering if there was something i could add to this code to also make the font red of the ones that get changed to 4 from na

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: VBA code for text to number

    This should do it

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-07-2012
    Location
    Nova Scotia, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA code for text to number

    thank you for your quick response but sometimes they input "4" and sometimes they input "na" which equals to 4 in the end and i need to distinguish the two, is there a way to do this?

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: VBA code for text to number

    Not sure if this is what you mean

    Please Login or Register  to view this content.

+ 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