Posted to microsoft.public.excel.programming
|
|
Add value to cell...
--
---
Regards,
Norman
"ctroyp" wrote in
message ...
Ok, I figured it out. Using the link provided I was able to get
started, but I had to use a public variable in order to run the
function across all cells on the sheet.
I am having one issue though. When selecting multiple cells, I get a
type-mismatch error when setting my accumulator value. Obviously I
don't want to select multiple cells to enter a value, but how can I
test for a multiple cell selection in the Worksheet_SelectionChange
event before setting the dblAcc value?
Here is the code:
Code:
--------------------
Public dblAcc As Double
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not IsEmpty(.Value) And IsNumeric(.Value) Then
dblAcc = dblAcc + .Value
Else
dblAcc = 0
End If
Application.EnableEvents = False
.Value = dblAcc
Application.EnableEvents = True
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
dblAcc = Target.Value
End Sub
--------------------
--
ctroyp
------------------------------------------------------------------------
ctroyp's Profile:
http://www.excelforum.com/member.php...o&userid=35321
View this thread: http://www.excelforum.com/showthread...hreadid=550972
|