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

DDT~123

Board Regular
Joined
May 31, 2012
Messages
219
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
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,402
Messages
5,601,475
Members
414,452
Latest member
Dannysamworth

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