Reputation: 2018
i need to write and excel macro to search for a string and replace it with another... how do i do this ? HELP :/
Upvotes: 0
Views: 6461
Reputation: 11996
Using user interface in Excel 2007
Using VBA code
Sub Replace_abc()
Sheets("Sheet1").Select
Range("A1").Select
Cells.Replace What:="abc", Replacement:="def", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
Upvotes: 2
Reputation: 46
You can record that operations, and Alt+Shift+F11 to open the Script Editor, then reference the code generated by the Recorder. I think that can give you some hints.
And I think you don't need to use Macro. It is enough to use the "Find and Replace" Menu Item, and choose the option you want.
Upvotes: 2