ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cells.Replace in VBA (https://www.excelbanter.com/excel-programming/343213-cells-replace-vba.html)

Gary''s Student

Cells.Replace in VBA
 
How do I specify workbook rather than sheet in Cells.Replace in VBA:

Cells.Replace What:="x", Replacement:="y", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
--
Gary''s Student

Tom Ogilvy

Cells.Replace in VBA
 
You don't. You can repeat the command on each sheet.

for each sh in Activeworkbook
sh.Activate
cells.Replace . . .
Next


--
Regards,
Tom Ogilvy

"Gary''s Student" wrote in message
...
How do I specify workbook rather than sheet in Cells.Replace in VBA:

Cells.Replace What:="x", Replacement:="y", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
--
Gary''s Student




Gary''s Student

Cells.Replace in VBA
 
Thank you . I now understand why the Macro Recorder generated the same code
either way.
--
Gary''s Student


"Tom Ogilvy" wrote:

You don't. You can repeat the command on each sheet.

for each sh in Activeworkbook
sh.Activate
cells.Replace . . .
Next


--
Regards,
Tom Ogilvy

"Gary''s Student" wrote in message
...
How do I specify workbook rather than sheet in Cells.Replace in VBA:

Cells.Replace What:="x", Replacement:="y", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
--
Gary''s Student





Jackes

Cells.Replace in VBA
 
I use the same thing but it impossible to control it on the sheet or on the
Workbook.

If you used manually the search and replacement command before the sub in
the workbook, the sub work for all sheets.

If you used manually in a sheet, the sub work for this sheet only.

The option for sheet or workbook seem not writable. My question is how is
possible to write my choice.

Sorry for my english, I am french.

"Tom Ogilvy" wrote:

You don't. You can repeat the command on each sheet.

for each sh in Activeworkbook
sh.Activate
cells.Replace . . .
Next


--
Regards,
Tom Ogilvy

"Gary''s Student" wrote in message
...
How do I specify workbook rather than sheet in Cells.Replace in VBA:

Cells.Replace What:="x", Replacement:="y", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
--
Gary''s Student






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

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