Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sum after every blank cell

Hello,

I love this website!! I have a problem that I am going nuts over. In
column A I have several numbers from A1 to A100
In that column there may be random blank spaces like A10 is blank, A15
is blank then A40 is blank.I would like a formula in column B that
sums A1to A9 then sums A11 to A14. Inotherwords, is there a formula
that will give me a sum after there is a blank cell?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Sum after every blank cell

On 28 Jan., 00:18, wrote:
Hello,

I love this website!! I have a problem that I am going nuts over. In
column A I have several numbers from A1 to A100
In that column there may be random blank spaces like A10 is blank, A15
is blank then A40 is blank.I would like a formula in column B that
sums A1to A9 then sums A11 to A14. Inotherwords, is there a formula
that will give me a sum after there is a blank cell?
Thanks


Hi

Try this macro.

Sub AddSumIfBlank()
Range("B1:B101").ClearContents
tCell = "A1"
tCell1 = "A1"
For c = 0 To 100
If Range(tCell).Offset(c, 0) = "" Then
tCell2 = Range(tCell).Offset(c, 0).Address
Range(tCell2).Offset(0, 1).Formula = "=SUM(" & tCell1 & ":" &
tCell2 & ")"
tCell1 = tCell2
End If
Next
End Sub


Regards,

Per
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sum after every blank cell

The macro works PERFECT. Can this only be achieved by macro or is
there a formula that can create the same results?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Sum after every blank cell

On 28 Jan., 04:32, wrote:
The macro works PERFECT. Can this only be achieved by macro or is
there a formula that can create the same results?


Sorry, but this can only be achieved by macro:-(

If you want the macro to run every time a number is entered or deleted
from the target range, try to put this in the macro sheet related to
the sheet containing the data.

Private Sub Worksheet_Change(ByVal Target As Range)
Set isect = Intersect(Range("A1:A100"), Target)
If Not isect Is Nothing Then

Range("B1:B101").ClearContents
tCell = "A1"
tCell1 = "A1"
For c = 0 To 100
If Range(tCell).Offset(c, 0) = "" Then
tCell2 = Range(tCell).Offset(c, 0).Address
Range(tCell2).Offset(0, 1).Formula = "=SUM(" & tCell1 &
":" & tCell2 & ")"
tCell1 = tCell2
End If
Next
End If
End Sub

Regards,

Per
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sum after every blank cell

Thanks, the second macro was exactly what I was looking for!
Reply
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
Average Formula to display blank cell if named range is blank Rachael F Excel Worksheet Functions 3 February 22nd 08 05:05 PM
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... [email protected][_2_] Excel Programming 2 June 7th 07 09:27 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Excel Programming 4 April 12th 07 08:56 PM
Copy to first Blank cell in Colum C Non blank cells still exist be Ulrik loves horses Excel Programming 2 October 8th 06 07:35 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM


All times are GMT +1. The time now is 12:44 PM.

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

About Us

"It's about Microsoft Excel"