View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Percentage Increase

"tb" wrote:
Yes my data is constant. Would you do me a favor and show me how
I should amend the VBA script which was suggested in the Microsoft
Community forum so that it also applies the percentage increase?
Sub RoundSelection()
Dim Cell As Range
For Each Cell In Selection
Cell.Value = WorksheetFunction.Round(Cell.Value, 2)
Next Cell
End Sub


Be sure to make a backup copy of the Excel file before trying anything.

Sub RoundSelection()
Const pctChange As Double = 0.07 ' for 7%
Dim Cell As Range
For Each Cell In Selection
Cell = WorksheetFunction.Round(Cell*(1+pctChange), 2)
Next Cell
End Sub

Change Round to Rounddown to truncate, or to Roundup to round up.

Note: Use WorksheetFunction.Round as shown, not the VBA Round function.
The latter rounds differently ("banker's rounding").