Running total macro issue

O

Onyx

Hello everyone, and thanks in advance for the help.

I sell a number of items and am using an excel sheet to keep track of
them. I currently have it set so that a number of buttons I click
increment a column of numbers that show how many I need to make of that
item (to replenish stock). I then have a 3rd column keeping track of how
many I have sold of that item. Here is an example:

Item A | 5 | 103

In this example, I have recently sold (and need to make) 5 of item A.
In the past I've sold 103 total.

Currently, I'm doing it all manually. I need a macro that will add the
numbers in column B into column C and then delete column B.

So in the example above, after running the macro, it would look like:

Item A | 0 | 108

I have a large number of rows I need this done on, and more rows may be
added in the future.

If you need any more information, please let me know.
 
P

Per Jessen

Hi

Add another button to "Update Totals", and call this macro (change the
Sub name as required. In my example qunatities recently sold is in
B2:B10.

Private Sub CommandButton1_Click()
Dim TargetRange As Range
Dim Cell As Range
Set TargetRange = Range("B2:B10")
For Each Cell In TargetRange
Cell.Offset(0, 1) = Cell.Offset(0, 1) + Cell.Value
Cell.Value = 0
Next
End Sub

Hopes this helps.
 

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