Need Macro Help

M

MS

I am working on a worksheet which has monthly payroll. I need to make a
macro which will go to the cell on the left, and remove a bracket in it
and a multiplication function in it.

For e.g. if A1 is =(221.86+1.15+3.75)*2, when i go to A2 I need the macro to
remove the brackets and the *2 so the result in A2 should be
=221.86+1.15+3.75. If I create the macro by keystrokes then wherever I am on
the workshet I get the same result as A1. So I need to use vb but dont have a
clue of the commands.

Any help will be sincerely appreciated.

Thankyou
MS
 
G

Gary''s Student

Sub ffixer()
Dim v As String
Set r = Range("A1")
v = r.Formula
n = Len(v) - 3
v2 = Replace(Left(v, n), "(", "")
r.Offset(1, 0).Formula = v2
End Sub
 
B

Billy Liddel

MS

Select the range and run the code

Sub test()
For Each c In Selection
If c.HasFormula Then
f = c.Formula
l = Len(f)
f = Left(f, Len(f) - 3)
f2 = Replace(Left(f, l), "(", "")
Debug.Print f2
c.Formula = f2
End If
Next
End Sub

Peter
 
Top