ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   makro that sums every new number entered in cell (https://www.excelbanter.com/excel-programming/280937-makro-sums-every-new-number-entered-cell.html)

Mario[_5_]

makro that sums every new number entered in cell
 
my problem:
i want to enter a number in A1
and everytime when u enter a number in a1 the macro adds the new number to
the old one BUT in the end there sould be the hole thing in the cell as
code...


A1 A1 - 0
input "14" in A1 A1 - 14
input "10" in A1 A1 - 24
input "-2" in A1 A1 - 22

at the end A1 = "14 + 10 - 2 " = 22

so that u can controll what is typed in

kind regards
mario



Andy Wiggins

makro that sums every new number entered in cell
 
This file might be a help:
http://www.bygsoftware.com/examples/...ainFormula.zip

It's in the "Worksheets with VBA" section on page:
http://www.bygsoftware.com/examples/examples.htm

It demonstrates how user input is captured and used to amend a formula with
the "SheetSelectionChange" event.

The code is open and commented.


--

Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"


"Mario" wrote in message
y.telekom.at...
my problem:
i want to enter a number in A1
and everytime when u enter a number in a1 the macro adds the new number to
the old one BUT in the end there sould be the hole thing in the cell as
code...


A1 A1 - 0
input "14" in A1 A1 - 14
input "10" in A1 A1 - 24
input "-2" in A1 A1 - 22

at the end A1 = "14 + 10 - 2 " = 22

so that u can controll what is typed in

kind regards
mario





Paul W Smith[_2_]

makro that sums every new number entered in cell
 
This may not be the most elegant solution but it works:


Public oldvalue
Public Done As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
If Done Then Exit Sub
If oldvalue = Target.Value Then Exit Sub
If Target.Address = "$A$1" Then
Done = True
[A1] = oldvalue + Target.Value
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < "$A$1" Then Exit Sub
oldvalue = Target.Value
Done = False
End Sub




"Mario" wrote in message
y.telekom.at...
my problem:
i want to enter a number in A1
and everytime when u enter a number in a1 the macro adds the new number to
the old one BUT in the end there sould be the hole thing in the cell as
code...


A1 A1 - 0
input "14" in A1 A1 - 14
input "10" in A1 A1 - 24
input "-2" in A1 A1 - 22

at the end A1 = "14 + 10 - 2 " = 22

so that u can controll what is typed in

kind regards
mario





J.E. McGimpsey

makro that sums every new number entered in cell
 
See one solution in .m.p.excel:




In article
lekom.at,
"Mario" wrote:

my problem:
i want to enter a number in A1
and everytime when u enter a number in a1 the macro adds the new number to
the old one BUT in the end there sould be the hole thing in the cell as
code...


A1 A1 - 0
input "14" in A1 A1 - 14
input "10" in A1 A1 - 24
input "-2" in A1 A1 - 22

at the end A1 = "14 + 10 - 2 " = 22

so that u can controll what is typed in

kind regards
mario




All times are GMT +1. The time now is 09:01 PM.

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