View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
MJKelly MJKelly is offline
external usenet poster
 
Posts: 114
Default Increasing and decreasing cell values

On Feb 8, 6:47 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Assuming your button's name is CommandButton1, use this click event to
add 1
for each button click...


Private Sub CommandButton1_Click()
ActiveCell.Value = ActiveCell.Value + 1
End Sub


For the minus 1 button, use the same code, but change the plus sign to a
minus sign.


Private Sub CommandButton2_Click()
ActiveCell.Value = ActiveCell.Value + 1
End Sub


Just select the cell you want to increment or decrement before clicking
the
buttons.


Thanks Rick.


Would this work for multiple selections at the same time?


No, but this should...

Private Sub CommandButton1_Click()
Dim C As Range
For Each C In Selection
C.Value = C.Value + 1
Next
End Sub

Rick


Rick,

That works brilliantly, thanks,

Matt