Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Replace fuction replacing all instead of selected cells

I have this code in a macro:

Sheets("Sheet 1").Select
For j = 9 To 39
Cells(j, "A").Replace What:="/", Replacement:="¦"
Cells(j, "A").Replace What:="\", Replacement:="|"
Cells(j, "A").Replace What:="[", Replacement:="€¹"
Cells(j, "A").Replace What:="]", Replacement:="ۼ"
Next j

The problem is instead of only looking in cells A9 to A39 in Sheet 1 for
these characters to replace the macro looks in ALL cells in ALL sheets in the
workbook!

Why is this?

Thanks
Clayton
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Replace fuction replacing all instead of selected cells

Found out why this is happening. In excel if I select Edit|Replace, Options
and I change the "Within" field from Workbook to Sheet the below works. Is
there a way to force "Within" to be Sheet in Vb?

"mcphc" wrote:

I have this code in a macro:

Sheets("Sheet 1").Select
For j = 9 To 39
Cells(j, "A").Replace What:="/", Replacement:="¦"
Cells(j, "A").Replace What:="\", Replacement:="|"
Cells(j, "A").Replace What:="[", Replacement:="€¹"
Cells(j, "A").Replace What:="]", Replacement:="ۼ"
Next j

The problem is instead of only looking in cells A9 to A39 in Sheet 1 for
these characters to replace the macro looks in ALL cells in ALL sheets in the
workbook!

Why is this?

Thanks
Clayton

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 do I find/replace data in selected cells only Mike_3333 Excel Worksheet Functions 7 April 3rd 23 07:45 PM
Copy and replace xlsm files, but retain the values in selected cells... ARbitOUR Excel Discussion (Misc queries) 1 April 24th 09 04:21 PM
Find/Replace Macro with format changes to the replacing number [email protected] Excel Programming 0 June 28th 06 06:08 PM
Using Replace command for replacing a character by an ALT+ENTER Peter from Novartis Excel Worksheet Functions 4 June 16th 06 02:57 PM
How do I replace an asterisk without replacing everything? Trw Excel Discussion (Misc queries) 4 June 9th 06 10:54 PM


All times are GMT +1. The time now is 10:39 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"