Thread: Text removal
View Single Post
 
Old 03-16-2022, 05:43 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

They following, based on your example, will work.


Code:
Sub Macro1()
Dim oTable As Table
Dim i As Long
Dim oRng As Range
Dim sText As String
    Set oTable = Selection.Tables(1)
    With oTable
        For i = 1 To .Rows.Count
            Set oRng = .Rows(i).Cells(1).Range
            If InStr(1, oRng.Text, "/") > 0 Then
                sText = Split(oRng.Text, "/")(0)
                If Not sText = "Income" And IsNumeric(sText) = False Then
                    oRng.Text = Trim(Split(oRng.Text, "/")(1))
                End If
            End If
        Next i
    End With
    Set oTable = Nothing
    Set oRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote