Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macro extracting text

Hello,

I have a problem to write a macro as below:
I have one column with long text and there are several thousands rows.
I have also a second column with about fifty rows with different words or
short three- words sentences in it.
I would like to have a macro that searches the first column for the same
words or short sentence as in the second column. If the word or the short
sentence is found in the first column , it is copied and pasted to the
third column.

Thank you very much in advance for help.

Tomek

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

Assume the first column is A1:A5000
second coumn is B1:B50

Sub CheckWords()
dim cell as Range, rw as Long
rw = 1
for each cell in Range("B1:B50")
if application.countif(A1:A5000,"*" & cell.Value & "*") 0 then
cells(rw,3).Value = cell.Value
rw = rw + 1
end if
Next
End Sub



--
Regards,
Tom Ogilvy


"Tomek" wrote in message
...
Hello,

I have a problem to write a macro as below:
I have one column with long text and there are several thousands rows.
I have also a second column with about fifty rows with different words or
short three- words sentences in it.
I would like to have a macro that searches the first column for the same
words or short sentence as in the second column. If the word or the short
sentence is found in the first column , it is copied and pasted to the
third column.

Thank you very much in advance for help.

Tomek



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macro extracting text

Dnia Mon, 31 Jan 2005 15:21:01 -0500, Tom Ogilvy napisał(a):

Assume the first column is A1:A5000
second coumn is B1:B50

Sub CheckWords()
dim cell as Range, rw as Long
rw = 1
for each cell in Range("B1:B50")
if application.countif(A1:A5000,"*" & cell.Value & "*") 0 then
cells(rw,3).Value = cell.Value
rw = rw + 1
end if
Next
End Sub


Something is wrong because when I try it I get a news " mismatch type"

Tomek
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro extracting text

typo/omission

if application.countif(A1:A5000,"*" & cell.Value & "*") 0 then
should be

if application.countif(Range("A1:A5000"), _
"*" & cell.Value & "*") 0 then

--
Regards,
Tom Ogilvy

"Tomek" wrote in message
...
Dnia Mon, 31 Jan 2005 15:21:01 -0500, Tom Ogilvy napisał(a):

Assume the first column is A1:A5000
second coumn is B1:B50

Sub CheckWords()
dim cell as Range, rw as Long
rw = 1
for each cell in Range("B1:B50")
if application.countif(A1:A5000,"*" & cell.Value & "*") 0 then
cells(rw,3).Value = cell.Value
rw = rw + 1
end if
Next
End Sub


Something is wrong because when I try it I get a news " mismatch type"

Tomek



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macro extracting text

Dnia Tue, 1 Feb 2005 23:01:46 -0500, Tom Ogilvy napisał(a):

typo/omission

if application.countif(A1:A5000,"*" & cell.Value & "*") 0 then
should be

if application.countif(Range("A1:A5000"), _
"*" & cell.Value & "*") 0 then


now it works but unfortunately it is not what I would like it to be.

I would like to have a macro that searches the first column for the same
words or short sentence as in the second column. If the word or the short
sentence is found in the first column , it is copied and pasted to the
third column.

so the third column should be filled with some words or short sentences but
when I run the macro it filled only several cells in third column but I
would like to have something like below:

A(words) B(conditions) C (results of macro)
aaaa aa aa
bbb bb bb
cccc ee nothing
aa aa
bb bb
fff nothing
cccc nothing
ggg nothing
aaa aa
ee ee

I am sorry very much for not explaining it clear enough.

Tomek


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro extracting text

Try this
in C2 put in a formula

=if(B2="","",if(countif(A2,"*"&B2&"*")0,B2,""))

then drag fill down column C.

--
Regards,
Tom Ogilvy

"Tomek" wrote in message
...
Dnia Tue, 1 Feb 2005 23:01:46 -0500, Tom Ogilvy napisał(a):

typo/omission

if application.countif(A1:A5000,"*" & cell.Value & "*") 0 then
should be

if application.countif(Range("A1:A5000"), _
"*" & cell.Value & "*") 0 then


now it works but unfortunately it is not what I would like it to be.

I would like to have a macro that searches the first column for the same
words or short sentence as in the second column. If the word or the short
sentence is found in the first column , it is copied and pasted to the
third column.

so the third column should be filled with some words or short sentences

but
when I run the macro it filled only several cells in third column but I
would like to have something like below:

A(words) B(conditions) C (results of macro)
aaaa aa aa
bbb bb bb
cccc ee nothing
aa aa
bb bb
fff nothing
cccc nothing
ggg nothing
aaa aa
ee ee

I am sorry very much for not explaining it clear enough.

Tomek



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 certain text Confused Excel Worksheet Functions 2 December 10th 08 05:09 PM
Extracting Text Mike Excel Worksheet Functions 7 May 17th 07 04:11 AM
Extracting Text Michael Excel Worksheet Functions 3 March 16th 06 07:32 PM
extracting text only Keith Excel Worksheet Functions 2 February 21st 05 12:57 PM
extracting text from within a cell - 'text to rows@ equivalent of 'text to columns' Dan E[_2_] Excel Programming 4 July 30th 03 06:43 PM


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