ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sum function (https://www.excelbanter.com/excel-programming/370863-sum-function.html)

[email protected]

sum function
 
hi all,

i need help on how to put a sum function at the end of the last (rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance


[email protected]

sum function
 
Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last (rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance



[email protected]

sum function
 
this work out good if i want the sum of only a1: to end of row..
but everytime the macro runs a new column is added. and this is the
column i want to have the sum

i have 2 headers on the top and like 12 values under it

week1
good

value 1
2
3
sum of all value




a écrit :

Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last (rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance



[email protected]

sum function
 
here is what i got for now .. but the sum formula dont show up in the
sheet. can someone help me

Dim GraphicWks As Worksheet
Dim DestCell As Range
Dim x As Range
Dim y As Range
Dim sumrng As Range


Set GraphicWks = Worksheets("calcul pour graphique")
With GraphicWks
Set DestCell = .Cells("3", .UsedRange.Columns.Count + 1)
Set x = .Cells("3", .UsedRange.Columns.Count)
Set y = .Cells(ActiveSheet.UsedRange.Rows.Count,
ActiveSheet.UsedRange.Columns.Count)
Set sumrng = Range(x, y)

End With



With DestCell
.Offset(17, 0).Formula = "=sum('" & sumrng
& "')"
End With


End Sub



please!

a écrit :

this work out good if i want the sum of only a1: to end of row..
but everytime the macro runs a new column is added. and this is the
column i want to have the sum

i have 2 headers on the top and like 12 values under it

week1
good

value 1
2
3
sum of all value




a écrit :

Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last (rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance



[email protected]

sum function
 
anyone have any idea on how to do this ???


a écrit :

here is what i got for now .. but the sum formula dont show up in the
sheet. can someone help me

Dim GraphicWks As Worksheet
Dim DestCell As Range
Dim x As Range
Dim y As Range
Dim sumrng As Range


Set GraphicWks = Worksheets("calcul pour graphique")
With GraphicWks
Set DestCell = .Cells("3", .UsedRange.Columns.Count + 1)
Set x = .Cells("3", .UsedRange.Columns.Count)
Set y = .Cells(ActiveSheet.UsedRange.Rows.Count,
ActiveSheet.UsedRange.Columns.Count)
Set sumrng = Range(x, y)

End With



With DestCell
.Offset(17, 0).Formula = "=sum('" & sumrng
& "')"
End With


End Sub



please!

a écrit :

this work out good if i want the sum of only a1: to end of row..
but everytime the macro runs a new column is added. and this is the
column i want to have the sum

i have 2 headers on the top and like 12 values under it

week1
good

value 1
2
3
sum of all value




a écrit :

Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last (rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance



Tom Ogilvy

sum function
 
Sub AddFormula()
Dim col as Column
set col = Cells(1."IV").End(xltoLeft).Column
cells(3,col).End(xldown)(2).Formula = "=Sum(R3C:R[-1]C)"
End Sub

--
Regards,
Tom Ogilvy

wrote in message
ps.com...
anyone have any idea on how to do this ???


a écrit :

here is what i got for now .. but the sum formula dont show up in the
sheet. can someone help me

Dim GraphicWks As Worksheet
Dim DestCell As Range
Dim x As Range
Dim y As Range
Dim sumrng As Range


Set GraphicWks = Worksheets("calcul pour graphique")
With GraphicWks
Set DestCell = .Cells("3", .UsedRange.Columns.Count + 1)
Set x = .Cells("3", .UsedRange.Columns.Count)
Set y = .Cells(ActiveSheet.UsedRange.Rows.Count,
ActiveSheet.UsedRange.Columns.Count)
Set sumrng = Range(x, y)

End With



With DestCell
.Offset(17, 0).Formula = "=sum('" & sumrng
& "')"
End With


End Sub



please!

a écrit :

this work out good if i want the sum of only a1: to end of row..
but everytime the macro runs a new column is added. and this is the
column i want to have the sum

i have 2 headers on the top and like 12 values under it

week1
good

value 1
2
3
sum of all value




a écrit :

Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last
(rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance




[email protected]

sum function
 
thanx tom .. but as column dont work

but i found something
..Offset(17, 0).FormulaR1C1 = "=SUM(R[-17]C:R[-1]C)"

and it's working !!




Tom Ogilvy a écrit :

Sub AddFormula()
Dim col as Column
set col = Cells(1."IV").End(xltoLeft).Column
cells(3,col).End(xldown)(2).Formula = "=Sum(R3C:R[-1]C)"
End Sub

--
Regards,
Tom Ogilvy

wrote in message
ps.com...
anyone have any idea on how to do this ???


a écrit :

here is what i got for now .. but the sum formula dont show up in the
sheet. can someone help me

Dim GraphicWks As Worksheet
Dim DestCell As Range
Dim x As Range
Dim y As Range
Dim sumrng As Range


Set GraphicWks = Worksheets("calcul pour graphique")
With GraphicWks
Set DestCell = .Cells("3", .UsedRange.Columns.Count + 1)
Set x = .Cells("3", .UsedRange.Columns.Count)
Set y = .Cells(ActiveSheet.UsedRange.Rows.Count,
ActiveSheet.UsedRange.Columns.Count)
Set sumrng = Range(x, y)

End With



With DestCell
.Offset(17, 0).Formula = "=sum('" & sumrng
& "')"
End With


End Sub



please!

a écrit :

this work out good if i want the sum of only a1: to end of row..
but everytime the macro runs a new column is added. and this is the
column i want to have the sum

i have 2 headers on the top and like 12 values under it

week1
good

value 1
2
3
sum of all value




a écrit :

Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last
(rigth
end ) column.

follow the number for the macro sequence of where the data is input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a new
sum


thx for the help in advance



Tom Ogilvy

sum function
 
That was a typo:

Sub AddFormula()
Dim col as Long
set col = Cells(1."IV").End(xltoLeft).Column
cells(3,col).End(xldown)(2).Formula = "=Sum(R3C:R[-1]C)"
End Sub

Looks like you would need to change your macro everyday. Don't see the
point of it.

Just enter the formula once and drag fill it across one cel each day.

--
Regards,
Tom Ogilvy


wrote in message
ps.com...
thanx tom .. but as column dont work

but i found something
..Offset(17, 0).FormulaR1C1 = "=SUM(R[-17]C:R[-1]C)"

and it's working !!




Tom Ogilvy a écrit :

Sub AddFormula()
Dim col as Column
set col = Cells(1."IV").End(xltoLeft).Column
cells(3,col).End(xldown)(2).Formula = "=Sum(R3C:R[-1]C)"
End Sub

--
Regards,
Tom Ogilvy

wrote in message
ps.com...
anyone have any idea on how to do this ???


a écrit :

here is what i got for now .. but the sum formula dont show up in the
sheet. can someone help me

Dim GraphicWks As Worksheet
Dim DestCell As Range
Dim x As Range
Dim y As Range
Dim sumrng As Range


Set GraphicWks = Worksheets("calcul pour graphique")
With GraphicWks
Set DestCell = .Cells("3", .UsedRange.Columns.Count + 1)
Set x = .Cells("3", .UsedRange.Columns.Count)
Set y = .Cells(ActiveSheet.UsedRange.Rows.Count,
ActiveSheet.UsedRange.Columns.Count)
Set sumrng = Range(x, y)

End With



With DestCell
.Offset(17, 0).Formula = "=sum('" & sumrng
& "')"
End With


End Sub



please!

a écrit :

this work out good if i want the sum of only a1: to end of row..
but everytime the macro runs a new column is added. and this is the
column i want to have the sum

i have 2 headers on the top and like 12 values under it

week1
good

value 1
2
3
sum of all value




a écrit :

Hi,
try this :
Sub SUMMING()
Dim oEnd As Object, r
Set oEnd = Range("A65536").End(xlUp)
r = oEnd.Row + 1
Range("A" & r).Formula = "=sum(a1:a" & oEnd.Row & ")"
End Sub

Rgds,

Halim

menuliskan:
hi all,

i need help on how to put a sum function at the end of the last
(rigth
end ) column.

follow the number for the macro sequence of where the data is
input.

| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |

3(sum of all 1) 4(sum of all 2)

after each run of the macro there is a new colomn of data and a
new
sum


thx for the help in advance





All times are GMT +1. The time now is 11:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com