VBA code for Sum and diff

D

dhir

I want VBA Code for formula which is like this

The Formula is in loop
i value keep on changing in loop
Di=Ai+B(i-1)-C(i-2)

So in D10 then formula should be like this =A10+B9-C8

I don't want R1C1 Method


I am trying for last two weeks...

Regards
Dhir
 
C

Claus Busch

Hi,

Am Sun, 24 Mar 2013 21:31:42 -0700 (PDT) schrieb dhir:
I want VBA Code for formula which is like this

The Formula is in loop
i value keep on changing in loop
Di=Ai+B(i-1)-C(i-2)

So in D10 then formula should be like this =A10+B9-C8

you don't have to loop. You can autofill the formula.
Try:

Sub Test()
Dim LRow As Long
LRow = Cells(Rows.Count, 1).End(xlUp).Row

Range("D3").Formula = "=A3+B2-C1"
Range("D3").AutoFill Range("D3:D" & LRow)
End Sub


Regards
Claus Busch
 

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