View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default copy formula using vba based on row count


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)


"Jeff" wrote in message
...
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.