View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default rounding a formula in a cell, then replace the formula

Hi
try the following macro
sub replace_formula()
dim oldform
dim newform
dim rng as range
dim cell as range
set rng=range("A1:A50")
for each cell in rng
if cell.hasformula then
oldform=cell.formula
newform = "=ROUND(" & right(oldform,len(oldform)-1) & _
",2)"
cell.formula=newform
end if
next
end sub


--
Regards
Frank Kabel
Frankfurt, Germany


Robert wrote:
I want to round 50 plus cells with the rounding formula. I want to
select the cell, enter the rounding formula that will round the
formula already in the cell and replace the original formula.
Example C10*C15 to ROUND(C10*C15,2). I tried doing this with a macro
and it doesn't work. The macro changes the original formula.