ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel percent adding macro (https://www.excelbanter.com/excel-programming/286332-excel-percent-adding-macro.html)

Fusto

Excel percent adding macro
 
When a user selects multiple cells in excel, and runs the macro, I need
an input box to appear requesting a number. That number is then the
percent amount that I want to times the cell by.

E.G
A1 = 1
A2 = 2
Inputbox = 7
A1 = 0.07
A2 = 0.14

Any assistance in this would be greatly appreciated...

Thanks


---
Message posted from http://www.ExcelForum.com/


Dale Hymel

Excel percent adding macro
 
Try This.

It gives additional option of selecting the range you want to
increase/decrease with the second input box

Sub Macro6()
Dim myPercent
Dim myRange As Range

myPercent = InputBox("Enter Percentage Increase, ie 25, 35 ")
If myPercent < 1 Then myPercent = myPercent * 100
myPercent = myPercent / 100
Set myRange = Application.InputBox("Select target cells to adjust",
Type:=8)
For x = 1 To myRange.Cells.Count
myRange.Cells(x) = myRange.Cells(x) * myPercent
Next x

End Sub


"Fusto" wrote in message
...
When a user selects multiple cells in excel, and runs the macro, I need
an input box to appear requesting a number. That number is then the
percent amount that I want to times the cell by.

E.G
A1 = 1
A2 = 2
Inputbox = 7
A1 = 0.07
A2 = 0.14

Any assistance in this would be greatly appreciated...

Thanks


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:05 PM.

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