Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Putting formula in cells from a loop

Hi - I want to put formulae in cells in my worksheet based on
itterating values.

For instance:

=sum("A2")
=sum("A3")
=sum("A4")
=sum("A5")

The way I thought to do it was from this loop

For ii = 1 To 5
Sheets("detail").Range("E" & Trim(Str(ii))).Formula =
"=sum(""A""&ltrim(str(ii)))"
Next ii

Whatever I try I get #NAME? in the cells on the worksheet.

Tried changing quotes, putting ampersands in etc.

Any ideas?

Thanks

Andrew

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Putting formula in cells from a loop

Hi Andrew,

change
= "=sum(""A""&ltrim(str(ii)))"

to
= "=sum(A" & Trim(Str(ii)) & ")"

or simply
= "=sum(A" & ii & ")"

you don't need the other Trim(Str(ii)) either

Regards,
Peter T

"Andreww" wrote in message
oups.com...
Hi - I want to put formulae in cells in my worksheet based on
itterating values.

For instance:

=sum("A2")
=sum("A3")
=sum("A4")
=sum("A5")

The way I thought to do it was from this loop

For ii = 1 To 5
Sheets("detail").Range("E" & Trim(Str(ii))).Formula =
"=sum(""A""&ltrim(str(ii)))"
Next ii

Whatever I try I get #NAME? in the cells on the worksheet.

Tried changing quotes, putting ampersands in etc.

Any ideas?

Thanks

Andrew



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
taking numbers in vertical cells putting them in horizontal cells jhawk22 Excel Worksheet Functions 4 April 28th 10 08:37 PM
Getting a filename into VBA and putting it into cells Babymech Excel Discussion (Misc queries) 2 February 27th 10 01:48 PM
Putting Multiple Cells into 1 FormulaQuestioner Excel Discussion (Misc queries) 10 October 1st 08 06:25 AM
how can I do this without actually putting into cells Papa Jonah Excel Programming 3 November 30th 04 02:34 PM
putting ' in a column of cells Peter McCaul Excel Programming 1 August 14th 04 06:11 PM


All times are GMT +1. The time now is 05:30 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"