Microsoft Office excel 2007 home & stude...

I have a spreadsheet of a lot of Data and I am having troubling finding a guide to take any cell and take 10% of the value away from it. I'd like to just select a cell or row and then simply click the button (or others who use the spreadsheet) and it reduce the current value by 10%.

In Addition, I'd like to somehow create a similar button that also adds 10 or 2 to the current selected cell or row.Please let me know if this is possible.

Thank you in advance.

Google something like Excel Command Buttonfor lots of hits on how to create a Command Button and assign a macro to it.This is just one of many sites: http://www.mrexcel.com/tip068.shtml

As far as the code required, your question isn't clear.

I understand the part about reducing the values in the selected cells by 10% and I'll provide code for that below.

However, this part is not clear:

a similar button that also adds 10 or 2Do you mean 10 or 2

percentor the actual value 10 or 2?

Do you want the code to randomly decide whether to add 10 or 2?

Do you want to be able to choose the value that is added after you click the button?

Do you a button specifically assigned to adding 10 and another button specifically assigned to adding 2?Please clarify.

Note: The following code checks to see that the value in each selected cell is a number. If it is, it reduces it by 10%, if not, it skips it. However, if the value is the result of a formula, it will replace the formula with the value minus 10% and the formula will be lost. You can't subtract 10% from a formula generated value and retain the formula since the formula would no longer be accurate.

If you study this code and understand how it works, you should be able to modify it to add your 10 or 2.

Sub Subtract10Percent() 'Loop through selected cells For Each myCell In Selection 'Check to make sure cell contains a number If IsNumeric(myCell) Then 'Add 10% myCell.Value = myCell - myCell * 0.01 End If Next End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Really appreciate the help. I did mean just to add by the value of 2 or 10. I will try the code right now.

Thank you so much.

Once again you've posted "2 or10" so your requirements are still unclear.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Ask Your Question

Weekly Poll