ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   EXCEL MACRO (https://www.excelbanter.com/excel-discussion-misc-queries/236224-excel-macro.html)

BobF

EXCEL MACRO
 
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.

Jim Thomlinson

EXCEL MACRO
 
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%.
--
HTH...

Jim Thomlinson


"BobF" wrote:

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.



All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com