Hi,
I haven't tested this, but it's probably: Cells(i, 14) = "=sum(RC[-" & x & "1]:RC[-" & y & "9])" Regards - Dave. > Date: Mon, 26 Jul 2010 20:09:45 -0700 > Subject: $$Excel-Macros$$ using variables as part of a "sum" function? > From: carlo.bitu...@gmail.com > To: excel-macros@googlegroups.com > > Hi, > this from a complete Excel VBA novice.... > > For i = 1 To 10 > Cells(i, 14) = "=sum(RC[-1]:RC[-9])" > Next i > > The above code snippet works, using the colums 1 and 9. > > Question: how would I use a variable instead of 1 and 9, > e.g. Cells(i, 14) = "=sum(RC[-x]:RC[-y])" > > -- > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > HELP US GROW !! > > We reach over 7000 subscribers worldwide and receive many nice notes about > the learning and support from the group.Let friends and co-workers know they > can subscribe to group at > http://groups.google.com/group/excel-macros/subscribe -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 7000 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe