Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Find exact text?

My macro searches for text in column headers from a list in a
spreadsheet and replaces that text with other text, also from the list.
For example, the first cell in the source spreadsheet might contain
"a", the cell to the right contains "b". The macro searches for "a" and
when it finds it, replaces it with "b". It then repeats itself using
the next row until it gets to a blank cell.
I have 2 column headers that are similiar, "stcounty" and "county". I
want to replace "stcounty" with "County of Inv" and "county" with
"County of Serv". Right now the macro replaces "stcounty" with "County
of Inv" but doesn't change "county" to "County of Serv". I've tried a
couple of different varations in the code, but can't get it to change
the second occurrence of "county". I'm sure someone here knows how to
fix this.
TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find exact text?

What value are you using for the LookAt argument?

you should be using xlWhole

LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlWhole or xlPart.



Note that the setting is persistent, so you shoud set it explicitely each
time your code uses the Find command.



--

Regards,

Tom Ogilvy



"davegb" wrote in message
oups.com...
My macro searches for text in column headers from a list in a
spreadsheet and replaces that text with other text, also from the list.
For example, the first cell in the source spreadsheet might contain
"a", the cell to the right contains "b". The macro searches for "a" and
when it finds it, replaces it with "b". It then repeats itself using
the next row until it gets to a blank cell.
I have 2 column headers that are similiar, "stcounty" and "county". I
want to replace "stcounty" with "County of Inv" and "county" with
"County of Serv". Right now the macro replaces "stcounty" with "County
of Inv" but doesn't change "county" to "County of Serv". I've tried a
couple of different varations in the code, but can't get it to change
the second occurrence of "county". I'm sure someone here knows how to
fix this.
TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Find exact text?

Wasn't using the LookAt argument, so I guess it must default to part. I
put it in as "whole" and the macro works great.
Thanks, Tom.

Tom Ogilvy wrote:
What value are you using for the LookAt argument?

you should be using xlWhole

LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlWhole or xlPart.



Note that the setting is persistent, so you shoud set it explicitely each
time your code uses the Find command.



--

Regards,

Tom Ogilvy



"davegb" wrote in message
oups.com...
My macro searches for text in column headers from a list in a
spreadsheet and replaces that text with other text, also from the list.
For example, the first cell in the source spreadsheet might contain
"a", the cell to the right contains "b". The macro searches for "a" and
when it finds it, replaces it with "b". It then repeats itself using
the next row until it gets to a blank cell.
I have 2 column headers that are similiar, "stcounty" and "county". I
want to replace "stcounty" with "County of Inv" and "county" with
"County of Serv". Right now the macro replaces "stcounty" with "County
of Inv" but doesn't change "county" to "County of Serv". I've tried a
couple of different varations in the code, but can't get it to change
the second occurrence of "county". I'm sure someone here knows how to
fix this.
TIA


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 exact value using LOOKUP kawfeehaus Excel Discussion (Misc queries) 8 November 3rd 09 03:27 AM
Routine to find exact Row matches in Col1 Col2 Col3 but exact offsetting numbers in Col4 [email protected] Excel Discussion (Misc queries) 0 June 11th 08 11:30 PM
How to find cells containing exact text, and separate them Tommy Excel Worksheet Functions 3 October 6th 06 01:49 AM
find (exact match) ? mark kubicki Excel Programming 1 December 7th 04 08:10 PM
Find a match that;s not exact Phyllis Excel Worksheet Functions 0 November 8th 04 08:12 PM


All times are GMT +1. The time now is 10:22 AM.

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"