+ Reply to Thread
Results 1 to 4 of 4

Breaking out Tax for each unique value

  1. #1
    Registered User
    Join Date
    12-18-2017
    Location
    United States
    MS-Off Ver
    10
    Posts
    13

    Question Breaking out Tax for each unique value

    Before
    Before Breakout.PNG

    After
    After Breakout.PNG

    I am thinking this is possible in VBA, the reason I think its possible is that I am able to write out the logic for it. However, I don't currently have the knowledge to make this work and this is the #1 problem we have with our invoicing. Here is my logic

    1. For each cell in Transaction Description look for "TAX"
    2. If found, assign activecell.currentregion to myRange
    3. Look for unique values in LINE PO column, and assign each unique value to a variable
    4. Insert a row at each change in unique value of LINE PO column
    5. Drag the last unique value down to fill recently inserted row
    6. Rename Transaction Desc in new row to TAX
    7. Divide TAX Value by (sum of account - TAX) to get TAX % || in this situation, it would be (9.16 / 111.30) = ~8.23%
    8. Multiple each variable SUM of Trans Amount by the percentage collected
    9. Insert the value on the new TAX line that was inserted

    Anyone have any ideas on where to start?

    *Edit: Included sample workbook
    Attached Files Attached Files
    Last edited by zombiehairdu; 01-23-2020 at 01:08 PM.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,522

    Re: Breaking out Tax for each unique value

    As this has been sitting a few days, I am offering a formula based proposal.
    This proposal adds two helper columns, which may be moved and/or hidden for aesthetic purposes to the 'Before' data range.
    The first helper column (Z) is populated using: =IF(W3="tax","",IF(OR(V4<>V3,W4="tax"),SUM(COUNTIFS(V$3:V3,V3),1,MAX(Z$2:Z2)),""))
    The second helper column (AA) is populated using: =IF(ISNUMBER(Z3),SUMIFS(Y$3:Y3,V$3:V3,V3)*(SUMIFS(Y$3:Y$7,W$3:W$7,"TAX")/SUMIFS(Y$3:Y$7,W$3:W$7,"<>TAX")))
    In the output data, the account, location and unique columns are populated using: =IF(MAX($Z$3:$Z$7)< ROWS($A$1:$A1),"",INDEX(T$3:T$7,AGGREGATE(15,6,(ROW(T$3:T$7)-ROW(T$2))/($Z$3:$Z$7>=ROWS($A$1:$A1)),1)))
    Column W is populated using: =IF(T17="","",IF(V18<>V17,"TAX",INDEX(W$3:W$7,AGGREGATE(15,6,(ROW(W$3:W$7)-ROW(W$2))/($T$3:$T$7=$T17)/($U$3:$U$7=$U17)/($V$3:$V$7=$V17),COUNTIFS($V$17:$V17,$V17)))))
    Column X is populated using: =IF(W17<>"MONTHLY STANDARD SVC TRASH","",INDEX(X$3:X$7,AGGREGATE(15,6,(ROW(W$3:W$7)-ROW(W$2))/($T$3:$T$7=$T17)/($U$3:$U$7=$U17)/($V$3:$V$7=$V17)/(W$3:W$7=W17),1)))
    Column Y is populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Registered User
    Join Date
    12-18-2017
    Location
    United States
    MS-Off Ver
    10
    Posts
    13

    Re: Breaking out Tax for each unique value

    Hey JeteMc,

    Thank you for trying to solve my problem. I am mostly able to make sense of each formula.

    I don't understand the purpose of this block
    Please Login or Register  to view this content.
    So you are counting how many times the unique# is found in the column, and then adding 1 to that number (I assume this is to account for the new tax line?) but the MAX() I don't understand its role.

    The AA Helper column makes sense, I could explain that one.

    The bottom cells I am almost entirely stumped. What exactly is happening?

    One final question, how easily can this be scaled? The entire spreadsheet is in the neighborhood of 257 accounts @ 4075 rows. I greatly appreciate your help.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,522

    Re: Breaking out Tax for each unique value

    The MAX() is used to add the number of rows that are already being assigned to the other unique's. If we had used SUM(COUNTIFS(V$3:V3,V3),1,Z2)) then in cell Z6 it would have displayed a value of 3 since cell Z5 is blank.
    As to rows 17:24 which are populated using four formulas, I am going to ask that you utilize the Evaluate Formula feature and watch at least one sample of each formula. If you have a specific questions afterwards I will do my best to explain.
    As to scaling, as long as the unique values change as shown in the sample file, then it should work. However it might be a good idea to upload another file, in a new post, that shows what happens to the unique values when the account and/or location changes.
    Let us know if you have any questions.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Breaking out Text from a Text String - Unique Characters
    By jhm5139 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-21-2017, 02:38 PM
  2. Hyperlinks keep breaking
    By Mnewton in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-10-2012, 10:26 AM
  3. Breaking up a sheet
    By thisandthat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2011, 01:05 AM
  4. Hyperlinks are breaking
    By texanjohn in forum Excel General
    Replies: 1
    Last Post: 10-19-2009, 08:45 AM
  5. breaking a tie
    By drltr6 in forum Excel General
    Replies: 5
    Last Post: 05-29-2009, 05:19 PM
  6. Breaking down Unique customer code.
    By Clash in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-07-2007, 10:17 AM
  7. Breaking a link.
    By Richard Buttrey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2005, 03:25 PM

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