![]() |
Range % Increase
I want to be able to select any given range of cells in my spreadsheet as
necessary and increase the numbers already in them by a percentage that I type into an InputBox. I'm familiar with the code for an Inputbox, but I'm struggling with how to tell Excel to move to each of the selected cells and perform the increase. The selected cells won't usually be in the same row or column, but rathered scattered about. Thanks! Steve C. |
Range % Increase
Steve:
try, Dim rng As Range p = InputBox("Input a percentage ", , 10) For Each rng In Selection rng.Value = rng.Value * Val(p) Next -- 天行健,君*以自強不息 地勢坤,君*以厚德載物 http://www.vba.com.tw/plog/ "Steve C" wrote: I want to be able to select any given range of cells in my spreadsheet as necessary and increase the numbers already in them by a percentage that I type into an InputBox. I'm familiar with the code for an Inputbox, but I'm struggling with how to tell Excel to move to each of the selected cells and perform the increase. The selected cells won't usually be in the same row or column, but rathered scattered about. Thanks! Steve C. |
Range % Increase
untested, but you shouldn't have to select the range.
just for each cell in rng.Name cell.value = cell.value*(your%) next cell -- Gary "Steve C" wrote in message ... I want to be able to select any given range of cells in my spreadsheet as necessary and increase the numbers already in them by a percentage that I type into an InputBox. I'm familiar with the code for an Inputbox, but I'm struggling with how to tell Excel to move to each of the selected cells and perform the increase. The selected cells won't usually be in the same row or column, but rathered scattered about. Thanks! Steve C. |
Range % Increase
Thanks! I will give it a try!
"chijanzen" wrote: Steve: try, Dim rng As Range p = InputBox("Input a percentage ", , 10) For Each rng In Selection rng.Value = rng.Value * Val(p) Next -- 天行健,君*以自強不息 地勢坤,君*以厚德載物 http://www.vba.com.tw/plog/ "Steve C" wrote: I want to be able to select any given range of cells in my spreadsheet as necessary and increase the numbers already in them by a percentage that I type into an InputBox. I'm familiar with the code for an Inputbox, but I'm struggling with how to tell Excel to move to each of the selected cells and perform the increase. The selected cells won't usually be in the same row or column, but rathered scattered about. Thanks! Steve C. |
All times are GMT +1. The time now is 07:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com