Hi,
I am trying to build a short macro that will add a multiplying factor to a cell formula while preserving the original formula between parentesis.
Example:
MyFactor = 1.5
Cell formula: =123+500/45 needs to become =(123+500/45)*1.5
I came up with the following code which give me: Run time error [1004]
Sub AddFactorToFormula()
'Add a multiplication factor in the formula to a range of cell
Dim C As Range
MyFactor = InputBox(Prompt:="Enter numeric factor")
For Each C In Selection
If Not IsEmpty(C) Then
C.Formula = "=(" & C.Formula & ")*" & MyFactor
End If
Next C
End Sub
Anyone knows the problem?
Thanks!
Louis
I am trying to build a short macro that will add a multiplying factor to a cell formula while preserving the original formula between parentesis.
Example:
MyFactor = 1.5
Cell formula: =123+500/45 needs to become =(123+500/45)*1.5
I came up with the following code which give me: Run time error [1004]
Sub AddFactorToFormula()
'Add a multiplication factor in the formula to a range of cell
Dim C As Range
MyFactor = InputBox(Prompt:="Enter numeric factor")
For Each C In Selection
If Not IsEmpty(C) Then
C.Formula = "=(" & C.Formula & ")*" & MyFactor
End If
Next C
End Sub
Anyone knows the problem?
Thanks!
Louis