Search & Replace

O

OVJ

I want to do a search and replace using info in cells on a work sheet. For
example, the search item in cell A1, the replace item in B1. Is there any way
to do this?
 
G

Gord Dibben

Sub find_replace()
Dim whatis As String
Dim withwhat As String
whatis = Range("A1").Value
withwhat = Range("B1").Value
Range("A2:F62").Select
Selection.Replace what:=whatis, Replacement:=withwhat, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1").Select
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top