• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

macro to get rid of part of formula

daveyc3000

New Member
hello, in certain cells, the formula is =sum(x1,x2,x3)+x4+x5

is there any way to make a macro get rid of anything AFTER the sum...ie x4 and x5?
 
sorry about the cross post

i asked my acquiantance and he suggested


Code:
   With Selection
    .Formula = Split(.Formula, ")")(0) & ")"
End With

seems to work...hope there's no volatility
 
I also got bored & came up with something. Not as high tech but does the job.

Code in the file is

Code:
Sub FormulaSplitter()

Dim MyFormula As String
Dim FormulaPartA As String
Dim FormulaPartB As String

MyFormula = Range("F2").Formula

FormulaPartA = Left(MyFormula, 14)
FormulaPartB = "=" & Right(MyFormula, 5)

'Obviously you could also use MID for splitting

Range("G2").Formula = FormulaPartA
Range("H2").Formula = FormulaPartB

End Sub
 

Attachments

Last edited:
Back
Top