Calculating sales tax using VBA in Microsoft Excel

 

 

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.

ArrowRawData

We will use custom function “SalesTax” to get the amount of sales tax. This function takes invoice and sales tax percentage as input.

ArrowOutput

Logic explanation

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)

We have used the above formula as it is in the “SalesTax” custom function.

 

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

 

If you liked this blog, share it with your friends on Facebook. Also, you can follow us on Twitter and Facebook.

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 info@exceltip.com



Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>