In this article, we will create a custom function to calculate sales tax for the given invoice and sales tax percentage.
Raw data for this example consists of invoice and sales tax percentage, we will calculate the amount of sales tax included in the amount in an invoice.
We will use custom function “SalesTax” to get the amount of sales tax. This function takes invoice and sales tax percentage as input.
Below mathematical formula is used to calculate the amount of sales tax when invoice and sales tax percentage are present.
SalesTax = TotalInvoice – TotalInvoice / (1 + TaxPercentage)
Please follow below for the code
Option Explicit Function SalesTax(TotalInvoice As Double, TaxPercentage As Double) 'Formula used for finding the sales tax SalesTax = TotalInvoice - TotalInvoice / (1 + TaxPercentage) End Function
We would love to hear from you, do let us know how we can improve our work and make it better for you. Write to us at email@example.com