LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Fad
 
Posts: n/a
Default Macro - define cell range for a sum function

Hello, I'm trying to sum certain cells in macro, however, the cell range is
not fixed;(i.e cells are based on variables)

Herebelow is an example of the macro but it's giving an error at the sum
funtion (would appreciate if you could help me find the mistake):

Sub R()
Dim i As Integer, x As Integer, y As Integer, z As Integer

For i = 2 To 15
y = i - z
x = i - 1
Cells(i, "H").Formula = "=Sum(Cells(y, "H"), Cells(x, "H"))"
z = 0
y = 0
x = 0
Next i
End Sub

Thank you
 
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
Passing a range name as an argument to the Index Function Michael Sharpe Excel Discussion (Misc queries) 3 September 5th 12 01:33 PM
Function to remove a space from text in cell WITHOUT macro?? [email protected] Excel Worksheet Functions 5 May 28th 05 02:28 AM
clock Wildman Excel Worksheet Functions 2 April 26th 05 10:31 AM
Function to determine if any cell in a range is contained in a given cell [email protected] Excel Worksheet Functions 3 February 7th 05 04:19 PM
Returning a Value to a Cell Based on a Range of Uncertain Size amc422 Excel Worksheet Functions 7 November 14th 04 03:03 PM


All times are GMT +1. The time now is 01:14 PM.

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

About Us

"It's about Microsoft Excel"