![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
Hello once more,
I have a serie of numbers in A1, B1, C1 to x1. I want to total the numbers from A1 to x1, the answer must stand in the cell next to x1!!! [A1].End(xlToRight)(1, 2).Value = Application.Sum(Range([A1], [A!].End(xlToRight))) This does the trick, BUT when I change a number the total doesn’t change. I must play the macro again and then it will. But I only want the macro to play just once. Therefore it must be a formula that stands in x1. How do I do that? The solution must be in VB!
__________________
Best regards, Martin J.A. Maatman Oonk |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
The following might do the trick, it will total the values in the first row from A1 to X1 and put the result in Y1: -
Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Count > 1 Then Exit Sub If Target.Row <> 1 Then Exit Sub Cells(1, 25).Formula = "=SUM(A1:X1)" End Sub |
|
|
|
|
|
#3 | |
|
Join Date: Feb 2002
Posts: 47
|
Quote:
Dim cell As Range Set cell = [A1].End(xlToRight)(1, 2) cell.Formula = "=SUM(A1:OFFSET(" & cell.Address(False, False) & ",0,-1))" |
|
|
|
|
|
|
#4 | ||
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
Quote:
How is it you know so much of VB?!?!
__________________
Best regards, Martin J.A. Maatman Oonk |
||
|
|
|
|
|
#5 | ||
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
Quote:
Then what code do I get.....???
__________________
Best regards, Martin J.A. Maatman Oonk |
||
|
|
|
|
|
#6 |
|
Join Date: Feb 2002
Posts: 47
|
Dim cell As Range
Set cell = [A1].End(xlDown)(2, 1) cell.Formula = "=SUM(A1:OFFSET(" & cell.Address(False, False) & ",-1,0))" |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|