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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,019
Members
448,938
Latest member
Aaliya13

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