LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Summing unknown number of rows

I'm trying to write code that will scan across a row, find
blank cells, and sum the fill area above it. I can't seem
to record a macro to do this though. When I use relative
referencing I get the following:

ActiveCell.Offset(-1, 0).Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(-2, 0).Range("A1:A4").Select
ActiveCell.Offset(1, 0).Range("A1").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"
ActiveCell.Offset(-3, 0).Range("A1:A4").Select
ActiveCell.Offset(-1, 0).Range("A1").Activate

Obviously this won't work because it references a set
number of rows. Does anyone know a good way to handle
this? The number of rows can vary from one to over 70.

Just for kicks, here's the rest fo my current code, which
hasn't been tested yet.

Sub Tester()

Dim cell As Range
For Each cell In Range("C2:C100")
If Right(cell.Offset(0, -2), 5) = "TOTAL" Then
ActiveCell.Rows("1:1").EntireRow.Select
For Each cell In Selection
If Right(ActiveCell.Value, 2) 0 Then
ActiveCell.FormulaR1C1 = ""
Else
If ActiveCell.Value = "" Then

Still obviously in progress, but I thought I'd post it
because I'm still nto too sure of myself.

Thanks in advance.
 
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
Summing a variable number of rows CEGavinMcGrath Excel Discussion (Misc queries) 4 August 28th 08 10:03 PM
Unknown formatting on inserted rows...? Bahookie Excel Discussion (Misc queries) 3 November 14th 06 01:13 PM
Formula's dealing with unknown number of rows OfficeNDN Excel Discussion (Misc queries) 2 September 11th 06 04:11 PM
Unknown Rows Darren Excel Discussion (Misc queries) 2 April 7th 06 10:57 PM
How to Calculate an unknown number? Beau Excel Worksheet Functions 1 May 28th 05 01:20 AM


All times are GMT +1. The time now is 08:41 AM.

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"