copy formula using vba based on row count

G

Guest

Hi all,
I have a spreadsheet that number of elements in Col A to Col D will
change (they have some # of items). e.g.
Row 1 is the header
Row 2 contain the descriptions.
Row 3 to whatever are the values.

Cell(E3).value = formula based on value in A3.. D3
Cell(E4).value = formula based on value in A4.. D4

How do I use VBA to copy the formula to the Col E based on number of items
in ColA?


Thanks.
 
B

Bob Phillips

iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 3 To iLastRow
Cells(i,"E").Formula = "=SUM(A" & i & ":D" & i & ")"
Next i

The formula will change to your formula.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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