+ Reply to Thread
Results 1 to 15 of 15

Multiple IF/Then assignments

Hybrid View

  1. #1
    Registered User
    Join Date
    10-25-2007
    Posts
    85

    Multiple IF/Then assignments

    Ok so what I need to do is set up an If/then macro that will populate anywhere from 1-11 columns based on some previous calcuations done. I'm having trouble with the formatting though.

    Im starting out with a number like 1001001164532, this is a Concatenated number that basically holds all the information about a person that I need tracked. Now these numbers can vary in length adding or subtracting at most 5 digits all taken from the right side and moving inward.

    So ill have my 11 max columns (number above is one involving 6 columns needing to be populated.) I was going to start with a simple comparison of that number vs the baseline amount of digits so is 1001001164532 greater than 1000000000000, if it is then a formula to extract the specific digits I need. something like (MID($P2,4,1)&LEFT($P2,3))*1
    If it failed the test then I want the cells to be blank.

    Firstly I'd like to know if there is a command that will just count digits so I can say If X has so many digits then do the formula or make it blank?

    Second I can't seem to get the formatting down to where it will actually populate the entire range of cells. I've tried Sheet4.CellsE:E but that does not work, I can't seem to find the proper format anywhere. Any help would be appreciated.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    I think you need to post an example.

  3. #3
    Registered User
    Join Date
    10-25-2007
    Posts
    85
    OK here is an example of what I'm trying to get it to look like. The ID number is the Conc. number I was talking about. Those last digits, the 164532 dictates how many columns there will be. That particular person has 6 calculations because of that. The next person would only have 5. What I want to do is set up an If/then statement that would check to see how many digits the ID has and based on that populate the correct columns with the formula I used in that example sheet. The max ends up being 11 seperate calculations and the minimum is one.

    So it'd be like
    If column A has X digits then column B = that formula else column B is blank

    and of course i'd make one for each of the different parameters, I just need to know the formatting that will make it actually fill out those columns.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-25-2007
    Posts
    85
    Sub ChoiceOne()
    Agent = Sheet4.Columns(1)
    FirstChoice = Sheet4.Columns(6)
    If Agent > 1 Then
    FirstChoice = (Mid(Sheet4.Columns(5), 8, 1) & Left(Sheet4.Columns(5), 7)) * 1
    Else
    FirstChoice = ""
    End If
    End Sub
    That is the code i've got in place now

    Fixed
    Last edited by Rgaherty; 10-29-2007 at 02:40 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    In B2 and copied down and right,

    =IF(LEN($A2) >= COLUMNS($A2:B2) + 6, MID($A2, COLUMNS($A2:B2) + 6, 1) & LEFT($A2, 7), "")

  6. #6
    Registered User
    Join Date
    10-25-2007
    Posts
    85
    Well, I put that into the sheet and applied it to those 11 columns, it works for all the numbers already there but when I tested by adding somone who had 8 choices vs the 6, it did not populate the two columns beyond the 6th. I can't really comment more than that because im not even 100% sure what everything in that formula was doing

    Thank you though.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    If the ID numbers go beyond 15 or 16 digits, they need to be stored as text. That's the limit of precision for IEEE Doubles.

    Format the ID cells as text, and enter strings as long as you wish.

  8. #8
    Registered User
    Join Date
    10-25-2007
    Posts
    85
    Ok, so I redid the formatting for the column it was drawing from to text. However it didnt seem to remedy the problem unfortunately. for some reason once I get to the 9th column to go into the conc formula it seems to turn all of those numbers to 0 rather than 9 10 and 11. Because of that when it goes through the calcuations those numbers also come out with 0 at the front instead of 9 10 or 11. Will I have to edit that formula to get it to take both digits of 10 and 11 into account on the later columns as well?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You've still got it stored as a number; that's why the ending digits are all zero.

    1. Format A2 as Text
    2. Enter a numeric (or alphanumeric) string as long as you wish.

  10. #10
    Registered User
    Join Date
    10-25-2007
    Posts
    85
    Right, I've formatted them as text. That puts them into the scientific form x.xxxx e^19 and so on. It doesnt change the values in the calculated cells when I do that. They still show up with 0 as the starting number.

+ 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