View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Sum a range of cells based on relative position

My example was misleading in that the Set code line was only there is indicate the reference cell.
If you are looping thru each cell in the selection, then sCell is automatically "Set" by Excel.
You don't need to and shouldn't set a reference to it during the loop.
On the other hand, the Offset and Resize parameters can be changed to reference different cell
locations.

Also, it is good practice to specify the parent sheet for a range.
Instead of "Range("B17") use Worksheets("Sludge").Range("B17")
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(Extras for Excel is useful)



"DaveO"
wrote in message
...
Thanks, Jim, I'll give it a shot. Because the relative position
changes with each loop, I'll need to modify your code to read

Set sCell = Range(sCell.Address)

... but that's exactly what I was looking for. Thanks!