+ Reply to Thread
Results 1 to 4 of 4

How do i add figures in excel based upon a condition?

  1. #1
    Registered User
    Join Date
    12-02-2011
    Location
    ohio
    MS-Off Ver
    Excel 2007
    Posts
    9

    Exclamation How do i add figures in excel based upon a condition?

    I'm trying to format security CUSIPs (must be 9 digits) in excel based upon the output a systems is giving me so that i can run vlookup formulas. The problem is that the system output will cut off the zeros if the cusip starts with zero. Ex: cusip 00817Y108 will be displayed as 817Y108. Sometime the system will cut off 1 or 2 zeros. I want to write an excel formula that will add a zero to the beginning of a cusip depending on how many zeros were cut off. So if i run a len formula on the cusip and it displays 7 or 8 i want the formula to add a zero to the beginning of the cusip so that it equals 9 digits.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How do i add figures in excel based upon a condition?

    Try: =REPT("0",9-LEN(A1))&A1

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    12-02-2011
    Location
    ohio
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How do i add figures in excel based upon a condition?

    Thanks for the post, I just added your formula to my if statement and it worked!


    =IF(F2=0,E2,CONCATENATE(REPT("0",9-LEN(E2))&E2))

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How do i add figures in excel based upon a condition?

    No need to use Concatenate, the & does the same trick.

    Dom

+ 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