Pls help on Macro - round formula

  • Thread starter Thread starter Eastar
  • Start date Start date
E

Eastar

A small data base
A B
1 3.3456 6.3535
2 4.5656 10.3265

Want to set up a macro to round the data,Macro as below
Range("d1:e2").Select
Selection.Formula = "ROUND(RC[-3],2)

The result I got is ROUND(RC[-3],2), instead of numbers (3.35, 6.36 .etc.)


thanks
 
You need an equals sign within the quotes as well:

Selection.Formula = "=ROUND(RC[-3],2)"

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(e-mail address removed)
Replace @mailinator.com with @tiscali.co.uk
 
How about adding the equal sign and using .formulaR1C1:
Selection.FormulaR1C1 = "=ROUND(RC[-3],2)"

Or even:
Range("d1:e2").formular1c1 = "=ROUND(RC[-3],2)"
(Dropping the .select line)

A small data base
A B
1 3.3456 6.3535
2 4.5656 10.3265

Want to set up a macro to round the data,Macro as below
Range("d1:e2").Select
Selection.Formula = "ROUND(RC[-3],2)

The result I got is ROUND(RC[-3],2), instead of numbers (3.35, 6.36 .etc.)

thanks
 
Thank you very much, guys

Dave Peterson said:
How about adding the equal sign and using .formulaR1C1:
Selection.FormulaR1C1 = "=ROUND(RC[-3],2)"

Or even:
Range("d1:e2").formular1c1 = "=ROUND(RC[-3],2)"
(Dropping the .select line)

A small data base
A B
1 3.3456 6.3535
2 4.5656 10.3265

Want to set up a macro to round the data,Macro as below
Range("d1:e2").Select
Selection.Formula = "ROUND(RC[-3],2)

The result I got is ROUND(RC[-3],2), instead of numbers (3.35, 6.36 .etc.)

thanks
 
Back
Top