Using Macro to post totals

E

elvisisdead

I have a very simple sheet that I use a barcode scanner to input the
barcodes of coupons. I use a vlookup to find the value of the coupon. I have
a total of the coupons in one cell. I want to write a macro that will copy
the total of the batch, paste it in a column, then delete the data entry
column. I did that with no problem. The problem is, how do I get batch
number 2 to past the value of the total in the row under the value of batch
number 1? I am currently overwriting the same cell. I would like to get a
grand total of all batches too. I have read about looping in VBS, but don't
fully understand the concept.

Thanks,

Elvis
 
D

Debra Dalgleish

The following macro will take the batch total from cell D1, and enter it
in the first empty row in column G. The current date is entered in the
same row, in column F.

Sub BatchTotal()
Dim c As Range
Dim r As Long
Dim ws As Worksheet

Set ws = Sheets("Sheet1")
r = ws.Cells(Rows.Count, "F") _
.End(xlUp).Row + 1

ws.Range("F" & r).Value = Date
ws.Range("G" & r).Value = ws.Range("D1").Value

End Sub
 
E

elvisisdead

Thank You! Thank You! Thank You! That was perfect. You saved me hours of
reading. Thanks again!

Elvis
 
D

Debra Dalgleish

You're welcome! I'm glad you were spared from hours of reading.

Also, you can remove the line:
Dim c As Range
which isn't required.
 

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