Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default copy formula using vba based on row count

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to count based on multiple criteria fields w/duplicates Excel-User-RR Excel Worksheet Functions 5 March 8th 09 12:48 AM
need formula to count non-zero items in an array based on a vlooku BKP Excel Worksheet Functions 2 September 17th 08 08:55 PM
can i copy any data which is based on formula Nitesh 9818662515 Excel Discussion (Misc queries) 2 January 4th 08 05:34 PM
Copy data based on a count... Brian Excel Worksheet Functions 0 August 10th 06 10:36 PM
formula to count based on data in two different cells/columns Cachod1 Excel Discussion (Misc queries) 3 January 30th 06 10:18 PM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"