ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   searching cells for a string of text (https://www.excelbanter.com/excel-programming/332288-searching-cells-string-text.html)

reddog9069

searching cells for a string of text
 

basically i am searching cells for a string of text.

Some of the cells have spaces before the string and some of them have
or 3 spaces between seperate words in the cell so it is hard to compar
for equality.

I cannot seem to get the Split() method to work when there is leadin
whitespace.

It seems to work fine otherwise.

Also I cannot get Trim() to work. No idea why.

May be I need to include some more references, but it is confusing m
greatly.

I am using office 2003 if that helps.

Any help would be greatly appreciated

--
reddog906
-----------------------------------------------------------------------
reddog9069's Profile: http://www.excelforum.com/member.php...fo&userid=2445
View this thread: http://www.excelforum.com/showthread.php?threadid=38054


Dave Peterson[_5_]

searching cells for a string of text
 
Just a complete guess. Maybe your cells don't contain spaces. If you've copied
and pasted from a web page, maybe it's those non-breaking spaces (in HTML
speak).

Chip Pearson has a nice addin that can help you determine each character in a
cell:
http://www.cpearson.com/excel/CellView.htm

If it turns out that you have spaces (or those non-breaking spaces), David
McRitchie has some code that will help clean this junk up:

http://www.mvps.org/dmcritchie/excel/join.htm#trimall
(look for "Sub Trimall()")

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

====
If it's none of this stuff, you may want to post more details--samples of what
you're looking for and samples of what the cells contain.

reddog9069 wrote:

basically i am searching cells for a string of text.

Some of the cells have spaces before the string and some of them have 2
or 3 spaces between seperate words in the cell so it is hard to compare
for equality.

I cannot seem to get the Split() method to work when there is leading
whitespace.

It seems to work fine otherwise.

Also I cannot get Trim() to work. No idea why.

May be I need to include some more references, but it is confusing me
greatly.

I am using office 2003 if that helps.

Any help would be greatly appreciated.

--
reddog9069
------------------------------------------------------------------------
reddog9069's Profile: http://www.excelforum.com/member.php...o&userid=24458
View this thread: http://www.excelforum.com/showthread...hreadid=380546


--

Dave Peterson


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com