+ Reply to Thread
Results 1 to 10 of 10

Integer vs long vs decimal

  1. #1
    Registered User
    Join Date
    12-09-2008
    Location
    USA
    MS-Off Ver
    Windows 7, Excel 2007
    Posts
    45

    Integer vs long vs decimal

    Hello,

    Take a look at the sample sheet. I get the information as an import that looks like the info in column A.

    I want it to look like the data in Column B. If I try to format as a number it always turns the last number to a 0. I also dont want the 0's on front of the digits either.

    I dont really care how its done. But I would like a routine to turn column A into and like the example in Column B. No zeros on the front and maintaining all numbers.

    Thank you for suggestions.
    Attached Files Attached Files

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    re: Integer vs long vs decimal

    You only get 15 digits of precision; if you have numbers larger than that, you need to format as text.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-09-2008
    Location
    USA
    MS-Off Ver
    Windows 7, Excel 2007
    Posts
    45

    Re: Integer vs long vs decimal

    Can you help me write a routine to get rid of the zeros on the front. These strings will be searched for, and I dont want to have to type 0's in the search box. Unfortunately I dont know a whole lot about strings.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Integer vs long vs decimal

    Assuming there's a non-zero character in the first 10 characters,

    =MID(A1, MATCH(TRUE, MID(A1, {1,2,3,4,5,6,7,8,9,10}, 1) <> "0", 0), 255 )

  5. #5
    Registered User
    Join Date
    12-09-2008
    Location
    USA
    MS-Off Ver
    Windows 7, Excel 2007
    Posts
    45

    Re: Integer vs long vs decimal

    Hello,

    I tired the line of code you made for me. I placed it in mine and I cant get it to work. The compiler does not like the brackets. So I took the brackets out and the compiler accepts the line. When I try to run, it gives me an error that there are to many arguments. Please refer to the attached xls sheet for example.


    Thank you again for your time.
    Attached Files Attached Files

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Integer vs long vs decimal

    It's a formula. Put it in B1 and copy down.

  7. #7
    Registered User
    Join Date
    12-09-2008
    Location
    USA
    MS-Off Ver
    Windows 7, Excel 2007
    Posts
    45

    Re: Integer vs long vs decimal

    Well, I want to run it in VBA. Did you look at the code in the example sheet? I cant just copy the formula into B1.


    Needs to be run in VBA


    Thanks again for your help, still open to suggestions.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Integer vs long vs decimal

    Please Login or Register  to view this content.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Integer vs long vs decimal

    Hello mtclimber,

    Here is a VBA macro that can be reused in your code. The macro resides in standard VBA module and not in the Sheet module. This allows you to use the macro with any worksheet and with any column of data in your workbook. This code has already been added to the attached workbook and to your command button.

    Module1 Macro Code
    Please Login or Register  to view this content.
    Worksheet1 CommandButton Code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  10. #10
    Registered User
    Join Date
    12-09-2008
    Location
    USA
    MS-Off Ver
    Windows 7, Excel 2007
    Posts
    45

    Re: Integer vs long vs decimal

    Leith Ross,

    Thank you for your help. I adapted your code to fit my project. I came across a problem which I worked out. And now it works fine. The problem was that everytime you clicked the command button it would continute to remove a digit until all the digits were gone, or until a empty cell came through.

    Also,
    I am new to coding. I have noticed that just about everyone has a different way to range areas. Although I did not use your way, I wanted to know what benifits it may offer. My project already had it's range established, I just needed the code for the MID functions and the loop.


    Again, thank you for your time. Attached is the finished code, adapted to axample of my project.

    Thanks again

    mtclimber
    Attached Files Attached Files

+ 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