Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Code to modify find/replace

I need a way to change the "Within" field from Workbook to Sheet in the find
and replace (options) command.

Is there a way to force "Within" to be Sheet in Vb?

Thanks
Clayton
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Code to modify find/replace

Hi Clayton

to replace "a" by "b" in sheet 1 of the active workbook use

ActiveWorkbook.Sheets(1).Cells.Replace What:="a", Replacement:="b"

Regards
Ingolf

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Code to modify find/replace

That's not quite what I ment.

If you click Edit|Replace in excel and then click options you will see a
pull down menu to change the Within field to "Sheet" or "Workbook". I need to
make sure it is set to "Sheet" before using something like:

ActiveWorkbook.Sheets(1).Cells("A1").Replace What:="a", Replacement:="b".

If the Within field is set to Workbook the above will replace EVERY
occurance of "a" to "b" in the ENTIRE workbook instead of just cell "A1".

Try it

Clayton

"Ingolf" wrote:

Hi Clayton

to replace "a" by "b" in sheet 1 of the active workbook use

ActiveWorkbook.Sheets(1).Cells.Replace What:="a", Replacement:="b"

Regards
Ingolf


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Code to modify find/replace

OK, I see. Another suggestion. Use a WorksheetFunction instead.

With ActiveWorkbook.Sheets(1)
.Range("A1") = _
Application.WorksheetFunction.Substitute(.Range("A 1"), "a", "b", 1)
End With

Ingolf


mcphc schrieb:

That's not quite what I ment.

If you click Edit|Replace in excel and then click options you will see a
pull down menu to change the Within field to "Sheet" or "Workbook". I need to
make sure it is set to "Sheet" before using something like:

ActiveWorkbook.Sheets(1).Cells("A1").Replace What:="a", Replacement:="b".

If the Within field is set to Workbook the above will replace EVERY
occurance of "a" to "b" in the ENTIRE workbook instead of just cell "A1".

Try it

Clayton

"Ingolf" wrote:

Hi Clayton

to replace "a" by "b" in sheet 1 of the active workbook use

ActiveWorkbook.Sheets(1).Cells.Replace What:="a", Replacement:="b"

Regards
Ingolf



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
Find and Replace Technique to modify stock symbols. Norm75 Excel Discussion (Misc queries) 2 July 7th 05 06:49 PM
Using code to mimic a find and replace ST Excel Programming 3 March 30th 05 12:52 PM
Find and Replace code in Sheet modules Jon Excel Programming 10 March 29th 05 10:15 PM
Find and Display / Modify code Soniya Excel Programming 0 October 12th 04 01:10 PM
Modify Find Code Al[_6_] Excel Programming 1 July 15th 03 10:35 PM


All times are GMT +1. The time now is 11:16 PM.

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

About Us

"It's about Microsoft Excel"