PC Review


Reply
Thread Tools Rate Thread

ActiveFormula R1C1

 
 
=?Utf-8?B?SnVuaW9yNzI4?=
Guest
Posts: n/a
 
      11th Jul 2007
Hi,

i am trying to sum a range of values from coloumn H to Column i. i is a
variable, and it depends on the input no for Cloumn F. If column F is 6, that
means that values need to be summed up from Column H to M( 6 columns
counting from H as a reference). but this does not work, can anyone advise
anything wrong with my code??? The result will be returned in Column G.

pls see code below:

Sub Book1()
Application.ScreenUpdating = False

Dim CurrentRow As Integer
Dim NumOfRows As Integer
Dim i As Integer


NumOfRows = Cells(Rows.Count, 1).End(xlUp).Row

For CurrentRow = 2 To NumOfRows
i = Cells(CurrentRow, "F").Value

With ActiveSheet
.Range("G2").Select
.Range("G" & CurrentRow).FormulaR1C1 _
= "=SUM(RC[1]:RC[i])"
End With
Next


Application.ScreenUpdating = True
End Sub


 
Reply With Quote
 
 
 
 
=?Utf-8?B?V2ltIFNLVw==?=
Guest
Posts: n/a
 
      11th Jul 2007
"Junior728" wrote:
> Hi,
>
> i am trying to sum a range of values from coloumn H to Column i. i is a
> variable, and it depends on the input no for Cloumn F. If column F is 6, that
> means that values need to be summed up from Column H to M( 6 columns
> counting from H as a reference). but this does not work, can anyone advise
> anything wrong with my code??? The result will be returned in Column G.


Why do you need a macro for this? Just put
=SUM(OFFSET(H1,0,0,1,F1))
in G1 and copy down.

-=Wim=-
 
Reply With Quote
 
=?Utf-8?B?SnVuaW9yNzI4?=
Guest
Posts: n/a
 
      11th Jul 2007
thanks Wim, you help me to find the right function in excel. At first, i dont
know what function can be used, and therefore i resort to VBA...

"Wim SKW" wrote:

> "Junior728" wrote:
> > Hi,
> >
> > i am trying to sum a range of values from coloumn H to Column i. i is a
> > variable, and it depends on the input no for Cloumn F. If column F is 6, that
> > means that values need to be summed up from Column H to M( 6 columns
> > counting from H as a reference). but this does not work, can anyone advise
> > anything wrong with my code??? The result will be returned in Column G.

>
> Why do you need a macro for this? Just put
> =SUM(OFFSET(H1,0,0,1,F1))
> in G1 and copy down.
>
> -=Wim=-

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
R1C1 stacia Microsoft Excel Misc 1 16th Feb 2010 06:46 PM
R1C1 stacia Microsoft Excel Misc 0 16th Feb 2010 06:19 PM
help on Converting R1C1 to A1 and A1 to R1C1..tia sa2 temp Microsoft Excel Programming 3 13th Sep 2007 08:31 AM
help on Converting R1C1 to A1 and A1 to R1C1..tia sa2 temp Microsoft Excel Misc 3 13th Sep 2007 08:31 AM
help on Converting R1C1 to A1 and A1 to R1C1..tia sa2 temp Microsoft Excel Worksheet Functions 3 13th Sep 2007 08:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:57 PM.