Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Irregular areas of numbers

Hi, how can I write code for counting numbers which are sometimes in
three, for or five?

Example:
1 2 3 4
A 12
B 14
C 25
D sum
E 35
F 64
G sum
H 87
I 12
J 46
K 77
L sum

I recorded this macro for one sum(f.e. in D1) and the code always
records the exact figure in three, so this code is not applicable to
other sums (G1 or L1)

This is the wrong macro:
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"



Any idea?

Thanx Marian

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Irregular areas of numbers

Marian,

If the Activecell is where you want to put the formula, and there is a
list of at least two numbers above the activecell, then

Sub CreateSumFormula2()
With ActiveCell
..Formula = "=Sum(" & Range(.Offset(-1, 0), _
.Offset(-1, 0).End(xlUp)).Address(False, False) & ")"
End With
End Sub

HTH,
Bernie
MS Excel MVP

"Marian" wrote in message
...
Hi, how can I write code for counting numbers which are sometimes in
three, for or five?

Example:
1 2 3 4
A 12
B 14
C 25
D sum
E 35
F 64
G sum
H 87
I 12
J 46
K 77
L sum

I recorded this macro for one sum(f.e. in D1) and the code always
records the exact figure in three, so this code is not applicable to
other sums (G1 or L1)

This is the wrong macro:
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"



Any idea?

Thanx Marian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Irregular areas of numbers

Marian,

With the activecell in column B, the macro below will do what you
want.

HTH,
Bernie
MS Excel MVP

Sub CreateSumFormulaInEachBlankCellOfCurrentColumn()
Dim myForm As String
Dim i As Integer

With ActiveCell.EntireColumn.SpecialCells(xlCellTypeBla nks)
For i = .Areas.Count To 1 Step -1
With .Areas(i).Cells(1)
If .Row < 1 Then
myForm = "=Sum(" & Range(.Offset(-1, 0), _
.Offset(-1, 0).End(xlUp)).Address(False, False) & ")"
.Formula = myForm
End If
End With
Next i
End With

End Sub



Hi Bernie,

I tried it and it didn't work. I attached the Excel file to this

post -
in yellow cells there I need sums. Could you please see at it?

THANX

Marian



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Irregular areas of numbers

Bernie Deitrick napsal(a):
Marian,

With the activecell in column B, the macro below will do what you
want.

HTH,
Bernie
MS Excel MVP

Sub CreateSumFormulaInEachBlankCellOfCurrentColumn()
Dim myForm As String
Dim i As Integer

With ActiveCell.EntireColumn.SpecialCells(xlCellTypeBla nks)
For i = .Areas.Count To 1 Step -1
With .Areas(i).Cells(1)
If .Row < 1 Then
myForm = "=Sum(" & Range(.Offset(-1, 0), _
.Offset(-1, 0).End(xlUp)).Address(False, False) & ")"
.Formula = myForm
End If
End With
Next i
End With

End Sub




Hi Bernie,

I tried it and it didn't work. I attached the Excel file to this


post -

in yellow cells there I need sums. Could you please see at it?

THANX

Marian




THANX Bernie :-)

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
Reducing numbers by one in defined areas over several sheets Colin Hayes Excel Worksheet Functions 12 April 17th 08 07:09 PM
Troubles with irregular dates Haz[_2_] Charts and Charting in Excel 5 April 22nd 07 03:51 PM
Irregular Payment Functions Steve Excel Worksheet Functions 0 November 14th 06 11:33 PM
sorting numbers with an irregular number of digits hearthd Excel Discussion (Misc queries) 5 October 8th 06 06:42 PM
how to add numbers from different areas in chart and importing forms from word carole New Users to Excel 1 June 12th 06 12:38 AM


All times are GMT +1. The time now is 05:38 AM.

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"