ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find and replace in excel (https://www.excelbanter.com/excel-programming/359367-find-replace-excel.html)

reena[_10_]

Find and replace in excel
 

I want to write a macro by which I can search a value 'DataA' in my
excel sheet and replace it by value 'DataB'.


--
reena
------------------------------------------------------------------------
reena's Profile: http://www.excelforum.com/member.php...o&userid=30440
View this thread: http://www.excelforum.com/showthread...hreadid=534496


Bondi

Find and replace in excel
 
Hi Reena,

This is freshly recorded :)

Sub Replace()
Cells.Replace What:="DataA", Replacement:="DataB",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

Regards,
Bondi


Mat P:son[_2_]

Find and replace in excel
 
Or, in fact, if you don't actually have a particular need for a macro to do
it then why not select the Edit Find... menu item to bring up the Find and
Replace dialogue. I'm convinced that you've seen it a million times before,
but you may still be surprised over how feature-rich it actually is (e.g.,
turn on the Advanced Mode by pressing the Options... button, and why not
check out the Format search options as well).

Not everything needs to be done programmatically :o) But if you want to,
then by recording your actions as a macro naturally helps a lot while trying
to figure out exactly what Excel objects to manipulate, and what params to
use.

Good luck Reena,
/MP

"Bondi" wrote:

Hi Reena,

This is freshly recorded :)

Sub Replace()
Cells.Replace What:="DataA", Replacement:="DataB",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

Regards,
Bondi




All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com