EXCEL MACRO

B

BobF

I need to know how to create a macro to increase the value of any given
individual cell by a certain percentage. I want to assign a control button to
the macro as well.
 
J

Jim Thomlinson

In a standard code module (the same place as the code for a recorded macro
lands) place the following procedure.

Public Sub ChangePercent()
Dim rng As Range

On Error Resume Next
For Each rng In Selection
rng.Value = rng.Value * 0.5
Next rng

End Sub

Add a command button from the forms toolbar to a worksheet and when prompted
select this macro. It changes the values of all selected cells by 50%.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top