VBA for finding a text string and replacing with text in another cell

DDT~123

Board Regular
Joined
May 31, 2012
Messages
220
Greetings All,

I'm needing help with VBA which would find the word "FMLA" which will be in Column D, and replace the text in Column A with an "X".

The code I'm using for other searches on the spreadsheet is
Code:
   Cells.Replace What:="Total", Replacement:="X Total", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

nuked

Well-known Member
Joined
Mar 20, 2013
Messages
883
Code:
Option Explicit

Sub PutX()

On Error GoTo errhandler

ActiveSheet.Columns("D").Find("FMLA").Offset(, -3) = "X"

Exit Sub

errhandler:

    MsgBox "Not found"
    Err.Clear
    
End Sub
 

Bairn90

New Member
Joined
Jun 2, 2012
Messages
28
Code:
Sub Find()


For Each cell In Range("D1:D100")
If cell.Value = "FMLA" Then
cell.Offset(0, -3).Formula = "X"
End If
Next cell


End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,857
Messages
5,834,008
Members
430,251
Latest member
fscrn_ffg

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
Top