Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Putting formula in cells from a loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andreww - 13 Feb 2007 11:36 GMT
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
Peter T - 13 Feb 2007 11:55 GMT
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

> Hi - I want to put formulae in cells in my worksheet based on
> itterating values.
[quoted text clipped - 22 lines]
>
> Andrew
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.