VBA to remove specific text from cells within a column

amxtomzo

Active Member
Joined
Nov 7, 2009
Messages
312
hello and thanks for looking

in column A, starting in row 4, there dates entered looking like this: "WED., 3/1" ( no quotes in the cells )

I would like to loop through column A, and remove all instances of "WED.,"
Leaving behind just the "3/1" part

I will later add to it, another loop
removing "TUE.,", THUR., and other days of the week

as always thank you very much

Thomas
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Maybe something like this (which you can continue to build off for the other days of the week):
Code:
Sub MyReplaceMacro()

    Dim lastRow As Long
    Dim myRange As Range
    
'   Find lastRow in column A
    lastRow = Cells(Rows.Count, "A").End(xlUp).Row

'   Set range to look at
    Set myRange = Range("A4:A" & lastRow)
    
'   Replace WED
    myRange.Replace What:="WED., ", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
'   Replace FRI
    myRange.Replace What:="FRI., ", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,229
Members
453,026
Latest member
cknader

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top