+ Reply to Thread
Results 1 to 14 of 14

remove decimal from field, append what was after decimal to before

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010/2007
    Posts
    4

    remove decimal from field, append what was after decimal to before

    Hi, I am trying to format some census tract data for a class project that has some cells that show up in the format "1234.56" but would like to remove the decimal and retain what was after it. the only manual way I can think of to do this would be to script text to columns to use the period as the separator, then send the decimal value to an arbitrary value that can just be recycled to hold the data and then maybe use an activecell & <arbitrary cell> to recall it. I'm stuck as to how to set the destination for the decimal data.

    Thanks in advance for any tips you can offer.

    p.s. i have to run out to take care of some things, so i appologize for any late replies.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: remove decimal from field, append what was after decimal to before

    Hi Bob, welcome to the forum.

    You should be able to simply multiple all the cells by 100. That will move the decimal to the right two places. You can type 100 in a cell. Select that cell, then copy it. Select your range of census data and right-click > PasteSpecial > Multiply. You can then delete the cell with 100 in it.

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: remove decimal from field, append what was after decimal to before

    you can also use find replace on numbers,replace . with nothing
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Contributor Russell Dawson's Avatar
    Join Date
    03-01-2012
    Location
    Yorkshire, England
    MS-Off Ver
    2007
    Posts
    608

    Re: remove decimal from field, append what was after decimal to before

    How about in B1 where data is in A1
    =RIGHT(A1,2)
    because as I read it all you want to do is retain the data following the decimal. Unusual I admit but that's how I read it. " . .remove the decimal and retain what was after it"
    This relies on all source data being to two decimal places.
    If I helped, please don't forget to add to my reputation. (click on the star below the post)

    If the problem is solved, please: Select Thread Tools (on top of your 1st post) -> Mark this thread as Solved.

    Failure is not falling down but refusing to get up.

  5. #5
    Registered User
    Join Date
    05-09-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010/2007
    Posts
    4

    Re: remove decimal from field, append what was after decimal to before

    Thank you all for the swift replies. Paul and Martin, those sound like viable options. Russell, you are correct in your interpretation. I don't quite understand how your solution would operate, but since this is my first experience wording with excel data that's to be expected. Being in GIS I'm sure I will be Needing to pick up a lot of handy tools. I will try out them all when I arrive home to get a feel for how each weighs for different situations. Thanks again for the tips. The multiply by 100 is so simple I'm mildly blushing to not have fought about it. I was overwhelmed by what I would have to do to script it that I didn't consider a more simple approach. I hope to learn and share in the years to come.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: remove decimal from field, append what was after decimal to before

    thats the way i read it too, Russel, and my suggestion would have been along the lines of yours, either extract the left to the . so they can be used, or extract to the right after the . for later use

    perhaps the OP can help us all understand better what he wants?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: remove decimal from field, append what was after decimal to before

    assuming your value is in A1 -

    to extract the values before the . use......

    =MID(A1,1,FIND(".",A1,1)-1)

    to extraxy after the . use...

    =MID(A1,FIND(".",A1,1)+1,5)

  8. #8
    Forum Contributor Russell Dawson's Avatar
    Join Date
    03-01-2012
    Location
    Yorkshire, England
    MS-Off Ver
    2007
    Posts
    608

    Re: remove decimal from field, append what was after decimal to before

    Very nice.

  9. #9
    Registered User
    Join Date
    05-09-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010/2007
    Posts
    4

    Thumbs up Re: remove decimal from field, append what was after decimal to before

    sample data has 3 main subtypes, a. 101, 102, etc b. 1000etc c. 1000.01 1000.02 ... 4803.01 etc

    From the stance I started with, it started with thinking of it as a text field, so I wanted to attach a lead and 2 trail zeros, so,

    Please Login or Register  to view this content.
    I was thrown off that it didn't seem to work, which reminded me that I needed to check my format settings (some strange flashback to freshmen year). this bit of code with the removal of the lead zero for four digit entries seemed appropriate but the decimal kind of threw a wrench into the plan.

    Now this leads me to think about what functions I should look into to decide which needs what. I'm thinking

    Please Login or Register  to view this content.
    I'm not entirely sure if syntax is correct, however i can worry about that later. I feel I should be able to put together something. I'll post a more final design while I mix and see what I can break.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: remove decimal from field, append what was after decimal to before

    why didn't you just find replace . ? if it didn't work please tell us why?

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: remove decimal from field, append what was after decimal to before

    Martin, in his 1st post, he said he wanted "but would like to remove the decimal and retain what was after it." i took that as remove the data after the . and retain it for later use...i could be wrong though, reading it again, you can read it both ways. his 2nd post (post #5) seems to confirm my read though?

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: remove decimal from field, append what was after decimal to before

    i read that as 23.23 becomes 2323 !

  13. #13
    Forum Contributor Russell Dawson's Avatar
    Join Date
    03-01-2012
    Location
    Yorkshire, England
    MS-Off Ver
    2007
    Posts
    608

    Re: remove decimal from field, append what was after decimal to before

    He told me that I was right (post #5) in my interpretation i.e. "retain the data following the decimal", which I took to mean solely the data after the decimal. I suppose the clue is in the title! Or not!

    It just goes to show how important it is to ask accurate questions.

    Pot-ay-ta, pot-ah-ta - tom-ay-ta, tom-ah-ta

    Lets call the . . . . .
    Last edited by Russell Dawson; 05-11-2012 at 02:41 AM. Reason: Humour

  14. #14
    Registered User
    Join Date
    05-09-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010/2007
    Posts
    4

    Re: remove decimal from field, append what was after decimal to before

    example starting cell format before parse(this will make sense if you read below)"Census Tract 1, Allegany County, Maryland"

    so here's what i came up with for my code. i format the column to text first so lead zeros stay, then i run parse first, (data actually is formatted with the county and state as well, and since my last post i found it would be better to save them so parse may not follow what my original posts said)
    then i run leadzerounder100000 to append lead zeros to values that are under 5 digits after multiplying by 100.

    martin, though the find ad replace would have worked for entries with a decimal, multiplying by 100 did the same thing, since if entries were formated "1234.1" vs "1234.01",(this time around they didn't have any like this however a different state's tracts may be different) the first would need a trail zero, since with census tracts are always 6 digits i would have to add an extra piece of code to append a trail zero, and at that point i would have forgotten which ones needed to be weeded out.

    Please Login or Register  to view this content.
    this project has definitely made me think about things more modularly. when i started i had macros in too many different modules and files, but now have cleaned it up and broken down into the bare necessities. thank you for all the help. if you see any things i could make it go faster, please feel free to pitch in. my current mode of automation is to hotkey the 3 functions then hold the hotkey down until all lines are finished =P (this would suck for 10,000's of records)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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