View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default adding the same formula to several cells without changing cell lin

Just don't run it on any cells that don't have a formula or any that already
have ROUND function.


Gord

On Wed, 17 Oct 2007 15:56:47 -0300, "Bernard Liengme"
wrote:

This will do it. Copy this subroutine to a general module. Select the cells
to change (remember you can select non-contiguous cell using CTRL); then run
the subroutine (Tools | Macro | Rum Macro)
Need help with VBA? See David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Sub wrapper()
For Each mycell In Selection
holdFormula = mycell.Formula
holdFormula = Mid(holdFormula, 2)
newFormula = "=ROUND(" & holdFormula & ",-2)"
mycell.Formula = newFormula
Next
End Sub

best wishes