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
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