Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Leo Leo is offline
external usenet poster
 
Posts: 5
Default Extracting whole word from cell

I have a troubles with code to extracting whole word like "count" from cells
My column for search looks like:
A B
1 count |
2 count for games |
3 account with |
4 counting for |
5 count and something |

I need to extract to column B valies from A where word "count"
appear WHOLE :
A B
1 count | count
2 count for games | count for games
3 account with | count and something
4 counting for |
5 count and something |

Find method doesn't work because it has 2 limits , xlWhole or xlParts,
with xlWhole I cannot get A2 and A3, with xlParts I get all 5 records

Thank for help
Leo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Extracting whole word from cell


-----Original Message-----
I have a troubles with code to extracting whole word

like "count" from cells
My column for search looks like:
A B
1 count |
2 count for games |
3 account with |
4 counting for |
5 count and something |

I need to extract to column B valies from A where

word "count"
appear WHOLE :
A B
1 count | count
2 count for games | count for games
3 account with | count and something
4 counting for |
5 count and something |

Find method doesn't work because it has 2 limits ,

xlWhole or xlParts,
with xlWhole I cannot get A2 and A3, with xlParts I get

all 5 records

Thank for help
Leo
.


You could try this:
Step 1) Concatenate a space (" ") to the beginning and end
of the cell value.
Step 2) Use the InStr function to look for the
word "count" within the resulting string
Step 3) If you find "count" then check to make sure the
character immediately before it is a space and the
character immediately after it is a space.

e.g.:
CheckStr = UCase(" " & Range(CellAddress).Value & " ")
FoundIt = InStr(CheckStr,"COUNT")
If FoundIt0 Then
SpaceBefore = (Mid(CheckStr,FoundIt-1,1) = " ")
SpaceAfter = (Mid(CheckStr,FoundIt+5,1) = " ")
If (SpaceBefore And SpaceAfter) Then
' Code to process the cell goes here
End If
EndIf


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Extracting whole word from cell


-----Original Message-----
I have a troubles with code to extracting whole word

like "count" from cells
My column for search looks like:
A B
1 count |
2 count for games |
3 account with |
4 counting for |
5 count and something |

I need to extract to column B valies from A where

word "count"
appear WHOLE :
A B
1 count | count
2 count for games | count for games
3 account with | count and something
4 counting for |
5 count and something |

Find method doesn't work because it has 2 limits ,

xlWhole or xlParts,
with xlWhole I cannot get A2 and A3, with xlParts I get

all 5 records

Thank for help
Leo
.


Silly me - easier is to use Like operator:

If UCase(Range(RangeAddress).Value) like "*COUNT*" then...

Also, if not obvious, you would need to put this into a
loop through your first range and then write code to copy
the relevant cells to the second range
  #4   Report Post  
Posted to microsoft.public.excel.programming
Leo Leo is offline
external usenet poster
 
Posts: 5
Default Extracting whole word from cell

"K Dales" wrote in message ...
-----Original Message-----
I have a troubles with code to extracting whole word

like "count" from cells
My column for search looks like:
A B
1 count |
2 count for games |
3 account with |
4 counting for |
5 count and something |

I need to extract to column B valies from A where

word "count"
appear WHOLE :
A B
1 count | count
2 count for games | count for games
3 account with | count and something
4 counting for |
5 count and something |

Find method doesn't work because it has 2 limits ,

xlWhole or xlParts,
with xlWhole I cannot get A2 and A3, with xlParts I get

all 5 records

Thank for help
Leo
.


Silly me - easier is to use Like operator:

If UCase(Range(RangeAddress).Value) like "*COUNT*" then...

Also, if not obvious, you would need to put this into a
loop through your first range and then write code to copy
the relevant cells to the second range




================================================== ==================
To K Dales:
Thank for help.
First decision work , second ( with Like ) - no,
but first do my job.

thanks
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
Extracting the last word from a string. Ciarán Excel Worksheet Functions 2 March 19th 10 02:21 PM
Extracting and replacing the first word in a String of text RAYCV Excel Worksheet Functions 5 August 21st 09 01:15 PM
Extracting a word from a text string Nadeem Excel Discussion (Misc queries) 3 October 12th 06 09:17 AM
Extracting specific word in a cell Conditional Formatting Excel Worksheet Functions 2 February 14th 06 09:57 PM
Extracting All But Last Word Steve Madden Excel Worksheet Functions 2 January 16th 06 05:22 PM


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