I want to automate the process of applying round formula on the same cell. So if A1 is 33.45 and I apply round formula it becomes =round(33.45,0) with the help of keyboard short-cut.
I ran a macro, changed some things and got the round function apply on the same cell using the below formula.
Sub Macro3()
'
'Macro3 Macro
'
'Keyboard Shortcut: Ctrl q
'
Active.Cell.FormulaR1C1 = Round(Active.Cell.FormulaR1C1,0)
ActiveCell.Offset(1,0).Range("A1").Select
End Sub
But I cannot get the end result to be written as =round(cell value,0)
Thank you in advance.
CodePudding user response:
try to change Active.Cell.FormulaR1C1 = Round(Active.Cell.FormulaR1C1,0) to Active.Cell.FormulaR1C1 = Round(ActiveCell,0)
by the way, what are you supposed to do with the second statement ActiveCell.Offset(1,0).Range("A1").Select? do you want to apply the round to current cell and them move to next line?
CodePudding user response:
This works for me:
Sub Macro3()
ActiveCell.Formula = "=round(" Str(ActiveCell.Value) ",0)"
End Sub
