Hi All. I have a macro that should strip the punctuation from the end of text in a range. When I run the macro it eliminates the text as well as the punctuation. Can someone please look at this code and tell me what I;m doing wrong? Thank you so much. I am including a spreadsheet with sample data. The code is below.
![]()
Sub StripPunctuation() '/====================================================================================================== '/ Procedure : StripPunctuation '/ Purpose : This procedure strips the punctuation from text in the range '/====================================================================================================== Dim wbTest As Workbook Dim wsTest As Worksheet Dim rngClean As Range Dim nRowOffset As Integer Dim vs As Variant nRowOffset = 1 Set wbTest = Workbooks("MyCleaningText") Set wsTest = wbTest.Worksheets("CleanTest") Set rngClean = wsTest.Range("B1") Do Until rngClean.Offset(nRowOffset).Text = "" With rngClean.Offset(nRowOffset) For Each vs In Array(".", "?", "!", "") .Replace What:=vs, _ Replacement:="", _ lookat:=xlPart, _ searchorder:=xlByRows, _ searchformat:=False, _ ReplaceFormat:=False Next vs End With Application.Wait Now() + #12:00:01 AM# nRowOffset = nRowOffset + 1 Loop Set wbTest = Nothing Set wsTest = Nothing Set rngClean = Nothing End Sub
Bookmarks