strInput – this is the text you want to replace bits of text from.This user defined function takes a text element and two ranges as input. StrTemp = Replace(strTemp, strFind, strReplace) StrReplace = rngReplace(cellFind.Row - rngFind.Row + 1, cellFind.Column - rngFind.Column + 1).Value If Not ((lngColFind = lngColReplace) And (lngRowFind = lngRowReplace)) Then So instead we will create a user defined function in VBA to simplify this. If you want to know how to use this VBA code then read this post about How To Use The VBA Code You Find Online.įunction REPLACETEXTS(strInput As String, rngFind As Range, rngReplace As Range) As String Now if we also want to replace bananas with chocolate we could do this by using a nested SUBSTITUTE formula.Īs we add more and more items we want to replace we need to nest more and more SUBSTITUTE functions and this will become more unmanageable. =SUBSTITUTE(SUBSTITUTE(A2,"apples","cookies"),"bananas","chocolate")
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |