vba. calculating cost with tax

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
986
Office Version
  1. 2010
Platform
  1. Windows
Hi.
Some sport event, the seating cost are orange seats $23.5. brown seats $19.75, and yellow seats $16.55. there is a tax of 6% on all seats.
the user can buy more than one seat, I need to know the cost of the seats with tax.

I tryed this but do not work
VBA Code:
Sub pseu()

'variables are: tickets, colour,  price,  cost, tax

Dim tickets As Integer
Dim color As String
Dim price As Integer
Dim cost As Integer
Dim tax As Integer



'enter number of tickets
tickets = Range("A1").Value



'enter colour of seats needed
Range("B1").Value = colour


'if the colour is orange then the price is 23.5
If colour = orange Then
price = 23.5
End If



' if the colour is brown then the price is 19.75
If colour = brown Then
price = 19.35
End If


' cost = number of tickets x price
cost = tickets * price
Range("C2").Value = cost



'tax = cost   x   6 %
tax = (cost * 6) / 100

Range("E2").Value = tax


'tell the number of tickets, tax and total cost
Range("D1").Value = "tickets" & tickets & "colour) & colour"
End Sub
Thanks for reading
I hope to hear from you
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Why do you need to use VBA? Will formulas work? If so please see below. Cell B2 has data validation set to List and the named range of "Color" contains the three colors for the dropdown selector.

Solutions 20210722.001.xlsm
ABCDEFGH
1# of TicketsColorCostTax Total CostBrown
21Yellow16.550.9917.54Orange
3Yellow
4
Sheet3
Cell Formulas
RangeFormula
C2C2=IFS(B2="Brown",19.75,B2="Orange",23.5,B2="Yellow",16.55,TRUE,0)*A2
D2D2=ROUND(C2*0.06,2)
E2E2=+C2+D2
Cells with Data Validation
CellAllowCriteria
B2List=Color
 
Upvote 0
Thanks cristal but it is not the answer I am looking for, the code I am trying have the pseudocode, the colors will be type on the cells and after calculated, but nice try, thanks.
 
Upvote 0

Forum statistics

Threads
1,223,922
Messages
6,175,406
Members
452,640
Latest member
steveridge

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top