Results 1 to 16 of 16

How do I strip punctuation from end of text?

Threaded View

  1. #1
    Registered User
    Join Date
    04-26-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    48

    How do I strip punctuation from end of text?

    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
    Attached Files Attached Files
    Last edited by egavasrg; 11-07-2011 at 10:36 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1