Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default problem with find and replacing

I have the following code, but he replaces also the numbers which were
already replaced.
How can I prevent that he will replace the cells which were already
replaced?
Maybe I can do it with a complete number or something like that?

This is my code:
Columns("F:F").Select
Selection.Replace What:="1", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="2", Replacement:="10", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="3", Replacement:="15", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="4", Replacement:="20", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="5", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="6", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="7", Replacement:="v.a. 35",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="24", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="X", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Y", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Z", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default problem with find and replacing


Yes - use xlWhole instead of xlPart

btw - once you set the replace parameters, they are saved and so:

With Selection
.Replace What:="1", Replacement:="0", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
.Replace "2", "10"
.Replace "Z", "v.a. 25"
End WIth


Regards,

Toyin.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default problem with find and replacing

Try changing xlPart to xlWhole

--
Regards,
Tom Ogilvy


"bartman1980" wrote:

I have the following code, but he replaces also the numbers which were
already replaced.
How can I prevent that he will replace the cells which were already
replaced?
Maybe I can do it with a complete number or something like that?

This is my code:
Columns("F:F").Select
Selection.Replace What:="1", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="2", Replacement:="10", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="3", Replacement:="15", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="4", Replacement:="20", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="5", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="6", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="7", Replacement:="v.a. 35",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="24", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="X", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Y", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Z", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default problem with find and replacing

On 8 aug, 15:50, Tom Ogilvy
wrote:
Try changing xlPart to xlWhole

--
Regards,
Tom Ogilvy



"bartman1980" wrote:
I have the following code, but he replaces also the numbers which were
already replaced.
How can I prevent that he will replace the cells which were already
replaced?
Maybe I can do it with a complete number or something like that?


This is my code:
Columns("F:F").Select
Selection.Replace What:="1", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="2", Replacement:="10", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="3", Replacement:="15", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="4", Replacement:="20", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="5", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="6", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="7", Replacement:="v.a. 35",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="24", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="X", Replacement:="v.a. 20",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Y", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Z", Replacement:="v.a. 25",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -


Thank you very much, it's working now!

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
Replacing one text with three in IF(ISERROR(FIND.......Max Steve Excel Worksheet Functions 4 May 14th 10 04:49 PM
Find/Replace Macro with format changes to the replacing number [email protected] Excel Programming 0 June 28th 06 06:08 PM
Pasting (replacing) problem berti Excel Discussion (Misc queries) 4 December 13th 05 10:38 AM
Fast Find possibly replacing .xls files Raul Excel Programming 0 March 15th 05 07:51 PM
INTRICATE PROBLEM- How to find multiple text,excluding "H", in a multiple range of cells, then replacing 0 with another number in another cell Tourcat Excel Worksheet Functions 1 February 8th 05 06:26 PM


All times are GMT +1. The time now is 11:47 AM.

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"