The code for both functions is :
Private Function TaxCalculate(Income As Currency, Sheet As Integer, StartingRow As Integer, StartingCol As Integer, Brackets As Integer)
'You must pass 5 values
' 1- Pass a CURRENCY as the amount of Income to calculate the tax on
' 2- Pass the SHEET number that the tax table is on
' 3- Pass the STARTING ROW of the Tax Table
' 4- Pass The STARTING COLUMM of the Tax Table (as number 1=A, 2=B, etc)
' 5- Pass the NUMBER of BRACKETS (Maximum is 20)
Dim Limits(20) As Currency
Dim PreviousTax(20) As Currency
Dim TaxRate(20) As Single
Dim Tax As Currency
' Load the Tax Table
For x = 0 To Brackets - 1
Limits(x + 1) = Worksheets(Sheet).Cells(StartingRow + x, StartingCol)
PreviousTax(x + 1) = Worksheets(Sheet).Cells(StartingRow + x, StartingCol + 1)
TaxRate(x + 1) = Worksheets(Sheet).Cells(StartingRow + x, StartingCol + 2)
Next x
' Calculate The Tax
For x = 1 To Brackets
If Income < Limits(x) Then
Tax = PreviousTax(x) + ((Income - Limits(x - 1)) * TaxRate(x))
Exit For
End If
Next x
TaxCalculate = Tax
End Function
I changed the name in the second workbook to rTaxCalculate
Bookmarks