how to reset a value in a cell after another

G

Guest

hello, i'm new here and i want some help from you guys. hope you'll help me
with this..

i want to create program in excel just like inventory of item sales. example

product Name ------------------>> name of product
quantity:____ ----------------->> quantity of the item sold will be input
here (i.e. 1)

total amount:_____------------------->> number inputted in quantity will
multiply by the fix retail price of prodcuct will be shown here.

I want to make a program like this---- after the amount is shown in the
Total amount Cell, I want the cell in a quantity where I input a number will
be reset to zero so I can input another quantity, but the new number that i
will input will be added to the previous number.

Hope you help me guysss.. more power.
 
M

Mike Fogleman

I have modified the two-cell accumulator method from the linked site to
match what you want.
Note: change "A1" to where your unit quantity is
change "A2" to where the cumulative total is
change "B1" to where the retail price is or substitute the price
for 'Range("B1").Value'
to hard code the number in the code


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "A1" Then 'change "A1" to where your
unit quantity is
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("A2").Value = Range("A2").Value + (.Value *
Range("B1").Value) 'change "A2" & "B1"
.Value = 0
Application.EnableEvents = True
End If
End If
End With
End Sub
 
G

Guest

Hi again..
thanks for the code. but I have a question where did i put the code? as I
said before I'm newbie and i dont know how to use visual basic together with
excel..
thanks again...
 
S

Steve

1) RightClick on the tab of the sheet where you need your accumulator
2) Click 'View Code'
3) Paste
 
G

Guest

Hi again...i get it i used to right click the tab and i inserted the code
the problem is when i run the program it ask for a macro name, if i put name
and run it again it displays error...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top