#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Input Cell

I would like to program a cell to be a number input cell
in excel and another cell to keep a sum of all the data
that inputed. What's the best way to do that.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Input Cell

Here is one that works for the SAME cell. Set up for A5.
Right click on sheet tabview codeinsert thissave workbook
Use 0 to start a new series
=====
Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" 'If Target.Value = oldvalue Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub




"Debbe" wrote in message
...
I would like to program a cell to be a number input cell
in excel and another cell to keep a sum of all the data
that inputed. What's the best way to do that.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Input Cell

This is almost exactly what I've been looking for. The only difference is
that I would like to have the new value placed in another cell, let's say
B5. So you would enter a new value in A5 and it would update B5 with the
old value plus the new value. Any thoughts on how do to this? Obviously, I
new to VBA.

Also, one minor error in the code you suggested. It should be:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub


"Don Guillett" wrote in message
...
Here is one that works for the SAME cell. Set up for A5.
Right click on sheet tabview codeinsert thissave workbook
Use 0 to start a new series
=====
Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" 'If Target.Value = oldvalue Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub




"Debbe" wrote in message
...
I would like to program a cell to be a number input cell
in excel and another cell to keep a sum of all the data
that inputed. What's the best way to do that.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Input Cell

OK try this one
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "A1" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("B1").Value = Range("B1").Value + .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


"Cody Dawg" wrote in message
...
This is almost exactly what I've been looking for. The only difference is
that I would like to have the new value placed in another cell, let's say
B5. So you would enter a new value in A5 and it would update B5 with the
old value plus the new value. Any thoughts on how do to this? Obviously,

I
new to VBA.

Also, one minor error in the code you suggested. It should be:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub


"Don Guillett" wrote in message
...
Here is one that works for the SAME cell. Set up for A5.
Right click on sheet tabview codeinsert thissave workbook
Use 0 to start a new series
=====
Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" 'If Target.Value = oldvalue Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub




"Debbe" wrote in message
...
I would like to program a cell to be a number input cell
in excel and another cell to keep a sum of all the data
that inputed. What's the best way to do that.







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Input Cell

Awesome!!! That was a major help - THANKS!

"Don Guillett" wrote in message
...
OK try this one
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "A1" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("B1").Value = Range("B1").Value + .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


"Cody Dawg" wrote in message
...
This is almost exactly what I've been looking for. The only difference

is
that I would like to have the new value placed in another cell, let's

say
B5. So you would enter a new value in A5 and it would update B5 with

the
old value plus the new value. Any thoughts on how do to this?

Obviously,
I
new to VBA.

Also, one minor error in the code you suggested. It should be:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub


"Don Guillett" wrote in message
...
Here is one that works for the SAME cell. Set up for A5.
Right click on sheet tabview codeinsert thissave workbook
Use 0 to start a new series
=====
Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" 'If Target.Value = oldvalue Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
'use this if needed if it stops working
Sub Fixit()
Application.EnableEvents = True
End Sub




"Debbe" wrote in message
...
I would like to program a cell to be a number input cell
in excel and another cell to keep a sum of all the data
that inputed. What's the best way to do that.








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
Input cell should display a percentage of input value in the cell Sherees Excel Discussion (Misc queries) 0 December 16th 09 10:25 PM
How to input pictures automatically based on cell input? bsharp Excel Worksheet Functions 9 May 30th 09 07:16 AM
I want excel to input data in a cell from multiple cell choices Pam Excel Worksheet Functions 7 March 11th 09 07:52 PM
run macro with input msg based on cell input Janelle S Excel Discussion (Misc queries) 0 January 20th 08 05:23 AM
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM


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

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

About Us

"It's about Microsoft Excel"