View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
GoodTrouble
 
Posts: n/a
Default How do I set the cell value to 0

Ok nevermind!! I got it, I just put the cell ranges that I just typed in
there into the code!! Duh! I should have known that! But how can I get it to
work with all the other ranges that I listed, I can only get it to work for
one range...do I just use a comma in between each range??
"Gary''s Student" wrote:

This tiny macro does what you want to cell A1, You can adapt it to any cell.

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Value = 0
Application.EnableEvents = True
End Sub

Remember that this is worksheet code. Right click on the tab, select view
code and paste the stuff in.
--
Gary's Student


"GoodTrouble" wrote:

I want the cell to change back to 0 after I type in a number and hit enter, I
have a formula in another cell that uses the number I enter, but if the cell
does not return to zero directly after I hit enter, it will keep adding
whatever number is in the cell. Please Help!