Click button = (value minus 1)

July 1, 2010 at 12:31:13
Specs: Windows XP, 3mhz/2 gig
Hi, I was wondering how this is done. Would you please help me? When I click the button, I want the value "tower" to subtract 1 from cell E2, and display the new result in E2.
Thank you

Private Sub CompaqTower_Click()
Range(e2).Value = Range(e2).Value - 1
End Sub

EDIT: Sorry, this is excel 2003.


See More: Click button = (value minus 1)

Report •


#1
July 1, 2010 at 14:54:25
Hi,

What do you mean by I want the value "tower" to subtract 1
A value can't do a subtraction.

What you have shown is presumably the code for the click event of a button named "CompaqTower"

When you click the button the value in cell E2 is decremented by 1.

Isn't that what you wanted ... E2 = E2-1

Or am I missing the point

Regards


Report •

#2
July 2, 2010 at 01:03:06
Hi Humar, that is correct. Maybe I was trying to get too technical. I cant get this to work though: (Yes CompaqTower is the button name)
Private Sub CompaqTower_Click()
E2 = E2 - 1
End Sub

Report •

#3
July 2, 2010 at 02:29:31
Got it.
Private Sub CompaqTower_Click()
Range("E4").value = Range("E4").value - 1
End Sub

Report •

Related Solutions

#4
July 2, 2010 at 05:14:01
Hi,

Glad you got it to work.

My fault - I tested the code on a button in one of my worksheets and it worked, but I didn't notice that you had missed the double quotes around the ranges:
Range("E4").value = Range("E4").value - 1

Regards


Report •

#5
July 2, 2010 at 05:47:58
Thanks humar, have a good one

Report •


Ask Question