VBA Solution Find and Replace

sachavez

Active Member
Joined
May 22, 2009
Messages
469
If cell in column A contains x, and cell in column E contains y, change text in column E to abcd.

Example, if cell in Column A contains "LOSANGELE", and cell in column E is "IY", then change "IY" to "abcd".

Thanks in advance
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
How about
Code:
Sub sachavez()
   Dim Cl As Range
   Dim St1 As String, St2 As String
   
   St1 = "AL"
   St2 = "IY"
   For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
      If InStr(1, Cl, St1, 1) > 0 And InStr(1, Cl.Offset(, 4), St2, 1) > 0 Then
         Cl.Offset(, 4) = "abcd"
      End If
   Next Cl
End Sub
 
Upvote 0
Better yet
Code:
Sub sachavez()
   With Range("A1:E1")
      .AutoFilter 1, "*AL*"
      .AutoFilter 5, "*IY*"
      .Parent.AutoFilter.Range.Columns(5).SpecialCells(xlVisible).Value = "abcd"
   End With
End Sub
 
Upvote 0
Went with this one first, and it's genius! Thank you very much for the help!


Better yet
Code:
Sub sachavez()
   With Range("A1:E1")
      .AutoFilter 1, "*AL*"
      .AutoFilter 5, "*IY*"
      .Parent.AutoFilter.Range.Columns(5).SpecialCells(xlVisible).Value = "abcd"
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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