HTML:
Excel 2010BCD1IncomePay PeriodFed22153Semi-monthlyCA3537[CENTER][COLOR=#161120][B]Tax Tables PDF Calcs[/B][/COLOR][/CENTER]
C2 is a drop list of four Pay Period choices.
D2 is a drop list with only two choices, CA or OC. CA will be used most often.
Table Base Number
HTML:
Excel 2010ABCDE5XWeeklyBiweeklySemi-MonthlyMonthly6AB36072078015597BC36673179215828CA24849553710729MB18036039078010NB19138141382511NL17234337174112NS17334537374613NT277553599119714NU255508550110015OC248495537107216ON285569617123317PE15631233867418QC000019SK312623675134820YT2484965371073[CENTER][COLOR=#161120][B]Tax Tables PDF Calcs[/B][/COLOR][/CENTER]
There are 58 different tax tables (We are excluding OC and QC for the purpose of this thread, we are including CA representing Canada) and each table has six pages. The first of the six pages begins with a range of numbers (the income must fall within this range), greater than zero (0) and less than... the number specified by the table above. ie looking for the first range for BC's Biweekly table would be 731.
HTML:
Excel 2010BCDE23WeeklyBiweeklySemi-MonthlyMonthly2424482548818268161834271224265228163234702920404486[CENTER][COLOR=#161120][B]Tax Tables PDF Calcs[/B][/COLOR][/CENTER]
Depending on the pay period the ranges on each table (on each of six pages) increase depending on the page you view.
For example on BC's Biweekly table, we might see the starting range of 0-731, because its biweekly, the next range for the rest of the page (a total of 55 rows including the first) will be a difference of 4, so you will see the ranges 0-731,731-735,735-739 and so on. The less than value of each range is actually a value of minus one cent however the table appears as stated. With this said, the next page (line one, page two) will begin with 947-955. I'm hoping you see where this is going.
This is where it gets tricky for me. It works with formulas and the worksheet I have added the ranges to, but I'm hoping someone could tell me how to store all of this in vba (an array or something?).
HTML:
Excel 2010ABCDE32NA0537FALSEFALSE33NA537753FALSEFALSE34NA7531193FALSEFALSE35Base11932183TRUE436NA21833613FALSEFALSE37NA36135483FALSEFALSE38NA54837903FALSEFALSE[CENTER][COLOR=#161120][B]Tax Tables PDF Calcs[/B][/COLOR][/CENTER]
Worksheet FormulasCellFormulaC32=D$3D32=IF(tween(B$2,B$32,C$32-0.01)=TRUE,TRUE,FALSE)E32=IF(D$32=TRUE,COUNTA(D$32:D$32),FALSE)A32=IF(tween(B$2,B32,C32-0.01)=TRUE,"Base","NA")A33=IF(tween(B$2,B33,C33-0.01)=TRUE,"Base","NA")A34=IF(tween(B$2,B34,C34-0.01)=TRUE,"Base","NA")A35=IF(tween(B$2,B35,C35-0.01)=TRUE,"Base","NA")A36=IF(tween(B$2,B36,C36-0.01)=TRUE,"Base","NA")A37=IF(tween(B$2,B37,C37-0.01)=TRUE,"Base","NA")A38=IF(tween(B$2,B38,C38-0.01)=TRUE,"Base","NA")B33=C$32C33=B$33+54*(HLOOKUP(C$2,B$23:E$29,COUNT(B$33:B$33)+1,FALSE))D33=IF(tween(B$2,B$33,C$33-0.01)=TRUE,TRUE,FALSE)E33=IF(D$33=TRUE,COUNTA(D$32:D$33),FALSE)B34=C$33C34=B$34+55*(HLOOKUP(C$2,B$23:E$29,COUNT(B$33:B$34)+1,FALSE))D34=IF(tween(B$2,B$34,C$34-0.01)=TRUE,TRUE,FALSE)E34=IF(D$34=TRUE,COUNTA(D$32:D$34),FALSE)B35=C$34C35=B$35+55*(HLOOKUP(C$2,B$23:E$29,COUNT(B$33:B$35)+1,FALSE))D35=IF(tween($B$2,B$35,C$35-0.01)=TRUE,TRUE,FALSE)E35=IF(D$35=TRUE,COUNTA(D$32:D$35),FALSE)B36=C$35C36=B$36+55*(HLOOKUP(C$2,B$23:E$29,COUNT(B$33:B$36)+1,FALSE))D36=IF(tween(B$2,B$36,C$36-0.01)=TRUE,TRUE,FALSE)E36=IF(D$36=TRUE,COUNTA(D$32:D$36),FALSE)B37=C$36C37=B$37+55*(HLOOKUP(C$2,B$23:E$29,COUNT(B$33:B$37)+1,FALSE))D37=IF(tween(B$2,B$37,C$37-0.01)=TRUE,TRUE,FALSE)E37=IF(D$37=TRUE,COUNTA(D$32:D$37),FALSE)B38=C$37C38=B$38+55*(HLOOKUP(C$2,B$23:E$29,COUNT(B$33:B$38)+1,FALSE))D38=IF(tween(B$2,B$38,C$38-0.01)=TRUE,TRUE,FALSE)E38=IF(D$38=TRUE,COUNTA(D$32:D$38),FALSE)
I'm hoping I've done this HTML correctly
HTML:
Excel 2010ABCDE32NA0537FALSEFALSE33NA537753FALSEFALSE34NA7531193FALSEFALSE35Base11932183TRUE436NA21833613FALSEFALSE37NA36135483FALSEFALSE38NA54837903FALSEFALSE[CENTER][COLOR=#161120][B]Tax Tables PDF Calcs[/B][/COLOR][/CENTER]
This range is using the previous tables to determine what table page the Income falls on, then with the next range (below) which of the 55 lines the income falls within.
HTML:
Excel 2010ABCD4211932147.002165.002156.000431211441229451247461265471283481301491319501337511355521373531391541409551427561445571463581481591499601517611535621553631571641589651607661625671643681661691679701697711715721733731751741769751787761805771823781841791859801877811895821913831931841949851967861985872003882021892039902057912075922093932111942129952147962165[CENTER][COLOR=#161120][B]Tax Tables PDF Calcs[/B][/COLOR][/CENTER]
Worksheet FormulasCellFormulaA42=VLOOKUP("Base",A$32:D$38,2,0)B42=LOOKUP(B$2,A$42:A$96)C42=B42+HLOOKUP(C2,B23:E29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)D42=MEDIAN(B42,C42)A43=IFERROR(A42+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A44=IFERROR(A43+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A45=IFERROR(A44+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A46=IFERROR(A45+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A47=IFERROR(A46+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A48=IFERROR(A47+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A49=IFERROR(A48+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A50=IFERROR(A49+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A51=IFERROR(A50+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A52=IFERROR(A51+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A53=IFERROR(A52+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A54=IFERROR(A53+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A55=IFERROR(A54+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A56=IFERROR(A55+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A57=IFERROR(A56+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A58=IFERROR(A57+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A59=IFERROR(A58+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A60=IFERROR(A59+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A61=IFERROR(A60+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A62=IFERROR(A61+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A63=IFERROR(A62+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A64=IFERROR(A63+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A65=IFERROR(A64+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A66=IFERROR(A65+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A67=IFERROR(A66+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A68=IFERROR(A67+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A69=IFERROR(A68+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A70=IFERROR(A69+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A71=IFERROR(A70+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A72=IFERROR(A71+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A73=IFERROR(A72+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A74=IFERROR(A73+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A75=IFERROR(A74+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A76=IFERROR(A75+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A77=IFERROR(A76+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A78=IFERROR(A77+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A79=IFERROR(A78+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A80=IFERROR(A79+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A81=IFERROR(A80+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A82=IFERROR(A81+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A83=IFERROR(A82+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A84=IFERROR(A83+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A85=IFERROR(A84+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A86=IFERROR(A85+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A87=IFERROR(A86+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A88=IFERROR(A87+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A89=IFERROR(A88+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A90=IFERROR(A89+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A91=IFERROR(A90+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A92=IFERROR(A91+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A93=IFERROR(A92+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A94=IFERROR(A93+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A95=IFERROR(A94+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)A96=IFERROR(A95+(HLOOKUP(C$2,B$23:E$29,VLOOKUP(TRUE,D$32:E$38,2,0),FALSE)),0)
It will first determine the base number for the table page (A42) and run all 55 rows greater than values. Then we find the less than value and find the median value from there. Another macro runs the median value as the income and determines the income tax deducted from source. The macro should be (with our tests it has been) within 2 cents of the tax found on the table.
I need this data stored in an array or something (replacing the worksheet ranges and formulas) so the application is less dependant on a specific worksheet.
Can someon please assist me with this?
Thank you
-- g