How to multiply user input value with rate and rate and store in a cell - VBA 6.5?

  • Thread starter Thread starter kk
  • Start date Start date
K

kk

Guest
Hi,
I would like to store the sales of 2 products in "Sale1" worksheet.
prod1 price is 7
prod2 price is 8
when the user inputs the prod1 quantity it should multiply Quantity and rate and store in coloumn C
and the same for prod2
Ex:
date 1/13/2011
name Mark
prod1 10
prod2 20

it should store it in "Sale1" as
date name prod1 prod2
1/13/2011 Mark 70 160


the code :

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

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

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtDate.Value
ws.Cells(iRow, 2).Value = Me.txtName.Value
ws.Cells(iRow, 3).Value = Me.txtprod1.Value
ws.Cells(iRow, 4).Value = Me.txtprod2.Value

'clear the data
Me.txtDate.Value = ""
Me.txtName.Value = ""
Me.txtprod1.Value = ""
Me.txtprod2.Value = ""
Me.txtDate.SetFocus
End Sub
 
Back
Top