Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Bony_Pony
 
Posts: n/a
Default VB Find and Replace

Hi all,
If I record a macro that does a find / replace on a sheet
and then record another one that does a Find / Replace on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

..... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the switch in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert

  #2   Report Post  
Bony_Pony
 
Posts: n/a
Default

I am using Excel ver 11 by the way


-----Original Message-----
Hi all,
If I record a macro that does a find / replace on a

sheet
and then record another one that does a Find / Replace

on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

..... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the switch in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert

.

  #3   Report Post  
Bony_Pony
 
Posts: n/a
Default

I am using Excel ver 11 by the way


-----Original Message-----
Hi all,
If I record a macro that does a find / replace on a

sheet
and then record another one that does a Find / Replace

on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

..... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the switch in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert

.

  #5   Report Post  
Bony_Pony
 
Posts: n/a
Default

Don hi and thank you for your help!

That worked - except now I have the other problem - when
I want to restrict a find / replace to a single sheet, it
now changes across the wole book - I tried selecting only
the sheet I wanted it to act on but it still changes all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Hi all,
If I record a macro that does a find / replace on a

sheet
and then record another one that does a Find / Replace

on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the switch

in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



  #6   Report Post  
Don Guillett
 
Posts: n/a
Default

Then just use a different macro or comment out the 1st and last lines.

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote in message
...
Don hi and thank you for your help!

That worked - except now I have the other problem - when
I want to restrict a find / replace to a single sheet, it
now changes across the wole book - I tried selecting only
the sheet I wanted it to act on but it still changes all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Hi all,
If I record a macro that does a find / replace on a

sheet
and then record another one that does a Find / Replace

on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa", Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the switch

in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



  #7   Report Post  
Bony_Pony
 
Posts: n/a
Default

Hi Don,
That's what I did but the replace still defaults to the
whole sheet. The only way I can restrict it, is via the
Find / Replace option on the Menu bar and if I set the
options to Sheet, it works for the sheet. I need to
switch this via VB though.

I have 2 situations - one where I will change the entire
contents of a workbook and other times that I want to
change a single sheet.

There are two seperate macros that control this.

I think Excel remembers the last Find / Replace selection
you made and applies it until it is changed manually.
What do you think?

Regards,
Robert
-----Original Message-----
Then just use a different macro or comment out the 1st

and last lines.

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Don hi and thank you for your help!

That worked - except now I have the other problem -

when
I want to restrict a find / replace to a single sheet,

it
now changes across the wole book - I tried selecting

only
the sheet I wanted it to act on but it still changes

all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony"

wrote
in message
...
Hi all,
If I record a macro that does a find / replace on a

sheet
and then record another one that does a Find /

Replace
on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",

Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",

Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the

switch
in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



.

  #8   Report Post  
Don Guillett
 
Posts: n/a
Default

try this

Sub replaceActiveSheetOnly()
ActiveSheet.Cells.Replace What:="aaa", Replacement:="bbb"
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote in message
...
Hi Don,
That's what I did but the replace still defaults to the
whole sheet. The only way I can restrict it, is via the
Find / Replace option on the Menu bar and if I set the
options to Sheet, it works for the sheet. I need to
switch this via VB though.

I have 2 situations - one where I will change the entire
contents of a workbook and other times that I want to
change a single sheet.

There are two seperate macros that control this.

I think Excel remembers the last Find / Replace selection
you made and applies it until it is changed manually.
What do you think?

Regards,
Robert
-----Original Message-----
Then just use a different macro or comment out the 1st

and last lines.

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Don hi and thank you for your help!

That worked - except now I have the other problem -

when
I want to restrict a find / replace to a single sheet,

it
now changes across the wole book - I tried selecting

only
the sheet I wanted it to act on but it still changes

all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony"

wrote
in message
...
Hi all,
If I record a macro that does a find / replace on a
sheet
and then record another one that does a Find /

Replace
on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",

Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",

Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the

switch
in
the Find / Replace Dialog box on the EDIT Menu bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



.



  #9   Report Post  
 
Posts: n/a
Default

Hi,
Tried that - actually it was the first thing I tried ...
sigh!!

Same result - it is the dropdown in the find / replace
that controls it no matter what selection I use in VBA.

Thanks anyway

Regards,
Robert
-----Original Message-----
try this

Sub replaceActiveSheetOnly()
ActiveSheet.Cells.Replace What:="aaa",

Replacement:="bbb"
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Hi Don,
That's what I did but the replace still defaults to the
whole sheet. The only way I can restrict it, is via

the
Find / Replace option on the Menu bar and if I set the
options to Sheet, it works for the sheet. I need to
switch this via VB though.

I have 2 situations - one where I will change the

entire
contents of a workbook and other times that I want to
change a single sheet.

There are two seperate macros that control this.

I think Excel remembers the last Find / Replace

selection
you made and applies it until it is changed manually.
What do you think?

Regards,
Robert
-----Original Message-----
Then just use a different macro or comment out the 1st

and last lines.

--
Don Guillett
SalesAid Software

"Bony_Pony"

wrote
in message
...
Don hi and thank you for your help!

That worked - except now I have the other problem -

when
I want to restrict a find / replace to a single

sheet,
it
now changes across the wole book - I tried selecting

only
the sheet I wanted it to act on but it still changes

all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony"

wrote
in message
...
Hi all,
If I record a macro that does a find / replace

on a
sheet
and then record another one that does a Find /

Replace
on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that

will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",

Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",

Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the

switch
in
the Find / Replace Dialog box on the EDIT Menu

bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



.



.

  #10   Report Post  
Don Guillett
 
Posts: n/a
Default

Make the manual change to sheets. Use the macros only. I just tested and
that works.

--
Don Guillett
SalesAid Software

wrote in message
...
Hi,
Tried that - actually it was the first thing I tried ...
sigh!!

Same result - it is the dropdown in the find / replace
that controls it no matter what selection I use in VBA.

Thanks anyway

Regards,
Robert
-----Original Message-----
try this

Sub replaceActiveSheetOnly()
ActiveSheet.Cells.Replace What:="aaa",

Replacement:="bbb"
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Hi Don,
That's what I did but the replace still defaults to the
whole sheet. The only way I can restrict it, is via

the
Find / Replace option on the Menu bar and if I set the
options to Sheet, it works for the sheet. I need to
switch this via VB though.

I have 2 situations - one where I will change the

entire
contents of a workbook and other times that I want to
change a single sheet.

There are two seperate macros that control this.

I think Excel remembers the last Find / Replace

selection
you made and applies it until it is changed manually.
What do you think?

Regards,
Robert
-----Original Message-----
Then just use a different macro or comment out the 1st
and last lines.

--
Don Guillett
SalesAid Software

"Bony_Pony"

wrote
in message
...
Don hi and thank you for your help!

That worked - except now I have the other problem -
when
I want to restrict a find / replace to a single

sheet,
it
now changes across the wole book - I tried selecting
only
the sheet I wanted it to act on but it still changes
all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony"
wrote
in message
...
Hi all,
If I record a macro that does a find / replace

on a
sheet
and then record another one that does a Find /
Replace
on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that

will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",
Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",
Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the
switch
in
the Find / Replace Dialog box on the EDIT Menu

bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



.



.





  #11   Report Post  
Don Guillett
 
Posts: n/a
Default

correction. Set manually to sheet. Use this for ALL and the activesheet one
for 1 sheet.

Sub replaceal1()
For Each ws In Worksheets
ws.Cells.Replace What:="bbb", Replacement:="aaa"
Next ws
End Sub
--
Don Guillett
SalesAid Software

wrote in message
...
Hi,
Tried that - actually it was the first thing I tried ...
sigh!!

Same result - it is the dropdown in the find / replace
that controls it no matter what selection I use in VBA.

Thanks anyway

Regards,
Robert
-----Original Message-----
try this

Sub replaceActiveSheetOnly()
ActiveSheet.Cells.Replace What:="aaa",

Replacement:="bbb"
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony" wrote

in message
...
Hi Don,
That's what I did but the replace still defaults to the
whole sheet. The only way I can restrict it, is via

the
Find / Replace option on the Menu bar and if I set the
options to Sheet, it works for the sheet. I need to
switch this via VB though.

I have 2 situations - one where I will change the

entire
contents of a workbook and other times that I want to
change a single sheet.

There are two seperate macros that control this.

I think Excel remembers the last Find / Replace

selection
you made and applies it until it is changed manually.
What do you think?

Regards,
Robert
-----Original Message-----
Then just use a different macro or comment out the 1st
and last lines.

--
Don Guillett
SalesAid Software

"Bony_Pony"

wrote
in message
...
Don hi and thank you for your help!

That worked - except now I have the other problem -
when
I want to restrict a find / replace to a single

sheet,
it
now changes across the wole book - I tried selecting
only
the sheet I wanted it to act on but it still changes
all
in everything. Any ideas?

regards,
Robert


-----Original Message-----
try this
Sub replaceall()
Sheets.Select
Cells.Replace What:="aaa", Replacement:="bbb
Sheets(1).Select
End Sub

--
Don Guillett
SalesAid Software

"Bony_Pony"
wrote
in message
...
Hi all,
If I record a macro that does a find / replace

on a
sheet
and then record another one that does a Find /
Replace
on
the entire workbook, they are identical!!

How can I code a Find / Replace statement that

will
always perform on all sheets in my workbook?

e.g.
This is the one for the sheet:
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",
Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

.... and this is the one for the workbook:

Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Cells.Replace What:="aaaa",
Replacement:="bbbbb",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False


The only way I can make it work, is to set the
switch
in
the Find / Replace Dialog box on the EDIT Menu

bar.
Anyone know how to switch that on in the macro??

Thanks for any help ...

Best regards,
Robert



.



.



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find replace text or symbol with carriage return jo New Users to Excel 11 April 4th 23 10:41 AM
macro to Find Replace in Excel Nurddin Excel Discussion (Misc queries) 7 January 3rd 05 04:29 AM
Find & Replace results to display specified chosen fields samuel Excel Discussion (Misc queries) 1 December 28th 04 08:43 AM
How Can I find and replace symbols in excel data ( white square) alawhizkid Excel Discussion (Misc queries) 1 December 14th 04 10:44 PM
Find & Replace questions David Excel Worksheet Functions 1 November 2nd 04 06:41 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"