Uerform + VBA Code + Calculation requirement Confusion

Joeclupis

Board Regular
Joined
Jun 18, 2016
Messages
63
Hello All,

Please excuse my poor attempts to describe my problem. I am trying to create a user form that will input the data into the sheet called "Test Sheet". In the "Test Sheet", there are some calculations that we perform. My question to the experts, more expert than me, is multi-fold:
1. is the code that I have started correct. I used google to search for something and then tried to make it match our column headers.
2. how can I perform the calculations to fill in the row. I would like the form to only have the entries that are needed for data entry, not any of the entries like Taxes or Will I have to input the data that never/rarely changes, i.e. taxes and total cost of fuel or sale price. Can I set up VBA code to pull it from a similar entry?

Here are the fields in my sheet:
1. Date
2. 100LL $ Update
3. JetA $ Update
4. 100LL Price Difference [calculation -- =SUM((100LL)previous update-current update)]
5. JetA Price Difference [calculation -- =SUM((JetA)previous update-current update)]
6. blank
7. 100LL QTY
8. 100LL Sales Price
9. JetA QTY
10. JetA Sales Price
11. Blank
12. Quantity /Delivered -- on form
13. Type Fuel Purchased -- on form
14. Wholesale Cost of Fuel -- on form
15. Taxes -- rather not have on form, but needs to be entered -- is static until State/Feds change rate
16. Total Cost of Fuel [calculation -- =(Wholesale cost +Taxes]
17. Sale Price
18. Mark-up [calculation -- =(Sale Price -Total Cost)]
19. Gross Profit [calculation -- =(Mark-up*Quantity Delivered)]

my code for the form is as follows:
Private Sub cbTypeFuel_Change()
cbTypeFuel.List = Array("100LL", "JetA", "91UL")
End Sub

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("test sheet")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row


'copy the data to the database
With ws
.Cells(iRow, 1).Value = Me.txtDate.Value
.Cells(iRow, 2).Value = Me.txt100LLupdate.Value
.Cells(iRow, 3).Value = Me.txtJETAupdate.Value
.Cells(iRow, 7).Value = Me.txt100LLqty.Value
.Cells(iRow, 9).Value = Me.txtJETAqty.Value
.Cells(iRow, 12).Value = Me.txtQTYDelivered.Value
.Cells(iRow, 13).Value = Me.txtTypeFuel.Value
.Cells(iRow, 14).Value = Me.txtWholesalePrice.Value
End With

'clear the data
Me.txtDate.Value = ""
Me.txt100LLupdate.Value = ""
Me.txtJETAupdate.Value = ""
Me.txt100LLqty.Value = ""
Me.txtJETAqty.Value = ""
Me.txtQTYDelivered.Value = ""
Me.txtTypeFuel.Value = ""
Me.txtWholesalePrice.Value = ""
Me.txtt.SetFocus

End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Joseph Carney, C.M.
Airport Operations
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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