Excel Vba Deleting a String of Character in a Range of Cells 3109 m9xh0d
-
Upload
kaustubh-rane -
Category
Documents
-
view
3 -
download
1
description
Transcript of Excel Vba Deleting a String of Character in a Range of Cells 3109 m9xh0d
-
Excel/VBA - Deleting a string of character ina range of cellsJune 2014
Excel/VBA - Deleting a string of character ina range of cellsIn the case you want to delete a word in a sentence, just create a small macrothat removes the word. But it will become difficult when you have word like, forexample, "Theword" or "THEWORD" or "theword" . Each of these word aredifferent, but contains the same characters. This little macro solves this problem.Option Explicit Option Compare Text
Sub DeleteWord() Dim Cel As Range, Range As Range Dim Word As String Set Range = Range("B2:B20") '. Word = "Theword" Application.ScreenUpdating = False For Each Cel In Range If Cel Like "*" & Word & "*" Then Cel = Replace(Cel, Word, "") 'To remove the double space that follows .. Cel = Replace(Cel, " ", " ") End If Next Cel Application.ScreenUpdating = True End Sub
This document entitled Excel/VBA - Deleting a string of character in a range of cells from Kioskea(en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page,under the conditions stipulated by the license, as this note appears clearly.