copy and paste formula using vb code

A

ASU

Can anybody tell me what vb code do I use for the following:
I would like it to copy and paste formula starting from columns "H11:L11"
everytime data is inserted in the cells, the code would paste the formula
down one row automatically.

Thank you
 
D

Dave O

Allow me to re-state it, to make sure I understand it properly:
When the user enters data in the range H11:L11, a formula is copied and
pasted down one row automatically.

If that is correct, where is the formula that is copied? If my
restatement is wrong, please correct it.
 
A

ASU

Yes , thats correct......eg. the formula in say "H11" is copied and pasted to
"H12". Like wise with cells "I11" through to "L11". The formula in "H11" is
as follows:

=SUMIF($A$3:A3,A3,$H$11:H11)-SUMIF($A$3:A3,A3,$E11:E11)

I'v tried dragging down, each column, to row 5000. But I found that it
slowed the file when opening and closing. Other way would to use vb codes to
do the maths!
 
L

lar.ridge

Try this code:
netrang = "H11:L11"
startrng = "H11"
Range(startrng) =
"=SUMIF($A$3:A3,A3,$H$11:H11)-SUMIF($A$3:A3,A3,$E11:E11)"
Range(startrng).AutoFill Destination:=Range(netrang), Type:=xlFillDefault

Larry
 

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