Page 1
Page 1
Started By
Message

Could use some Excel help... SOLVED and THANK YOU

Posted on 3/29/16 at 11:26 pm
Posted by SlapahoeTribe
Tiger Nation
Member since Jul 2012
12263 posts
Posted on 3/29/16 at 11:26 pm
I'm having a hell of a time getting something to work. I'd like to be able to enter a sentence into Column A and in Column B have it return all of the words from that sentence that are in a list of words from Column X.

Example (input, the numbers on the left are the row numbers):

...Column A

1 Frank drove 12 miles to the store.
2 Jane walked 2 miles to the beach.
3 Kevin flew 800 miles to go on vacation.
4 Sarah drove 15 hours across the state and then ran a marathon.

...Column X
1 walked
2 flew
3 drove
4 ran
5 biked


Example (what I want it to return to me):

...Column B

1 drove
2 walked
3 flew
4 drove, ran


This has been nagging me for a while now. Any help would be much appreciated.
This post was edited on 3/30/16 at 2:48 pm
Posted by retired trucker
midwest
Member since Feb 2015
5093 posts
Posted on 3/30/16 at 7:11 am to
sorry, not me maynard, BUT

did you think to look on amazon for one of them helper cards in plastic?

I recently bought an old adobe, and a helper card for shortcuts and stuff

it won't hurt to look
Posted by Stexas
SWLA
Member since May 2013
6558 posts
Posted on 3/30/16 at 8:35 am to
I have no idea what you're asking... Maybe I'm slow, but you have 1 word in column X and are returning 2 words in column B?

Some sort of If statement may help???
Posted by CubsFanBudMan
Member since Jul 2008
5745 posts
Posted on 3/30/16 at 8:42 am to
The first thing that comes to mind is nesting some find and mid commands with if error. How big is the list in column x?
Posted by CubsFanBudMan
Member since Jul 2008
5745 posts
Posted on 3/30/16 at 8:54 am to
Here's a starting point, but there are problems with it. It picked up the ran inside of Frank, so in order to keep that from happening I had to put a space in front of and in back of the words in column x. This means it won't pick up the first or last word in the sentence. Also, it is case specific, so it will not pick up the first word in the sentence. Also, I have extra commas.

=IFERROR(MID(A1,FIND($X$1,A1),LEN($X$1)),"")&","&IFERROR(MID(A1,FIND($X$2,A1),LEN($X$2)),"")&","&IFERROR(MID(A1,FIND($X$3,A1),LEN($X$3)),"")&","&IFERROR(MID(A1,FIND($X$4,A1),LEN($X$4)),"")&","&IFERROR(MID(A1,FIND($X$5,A1),LEN($X$5)),"")

Results:
,, drove ,,
walked ,,,,
, flew ,,,
,, drove , ran ,

Removing all of the commas:
=IFERROR(MID(A1,FIND($X$1,A1),LEN($X$1)),"")&IFERROR(MID(A1,FIND($X$2,A1),LEN($X$2)),"")&IFERROR(MID(A1,FIND($X$3,A1),LEN($X$3)),"")&IFERROR(MID(A1,FIND($X$4,A1),LEN($X$4)),"")&IFERROR(MID(A1,FIND($X$5,A1),LEN($X$5)),"")

Results:
drove
walked
flew
drove ran


Posted by msuhunter
Member since Aug 2014
5 posts
Posted on 3/30/16 at 9:37 am to
VBA:
Function GetWords(x As Range, List As Range)
GetWords = ""
For Each y In List.Cells
If InStr(x.Text, " " + y.Text + " ") > 0 Then
If Len(GetWords) > 1 Then
GetWords = GetWords + ", "
End If
GetWords = GetWords + y.Text
End If
Next
End Function

Excel:
=GetWords(A1,$B$1:$B$5)

This doesn't account for multiple uses of the same word but could be easily modified if needed.


Posted by mdomingue
Lafayette, LA
Member since Nov 2010
37888 posts
Posted on 3/30/16 at 10:26 am to
a VBA macro as pointed out by msuhunter is the way to go for this. You could probably do it via functions in the cell but it would probably be long and convoluted.
This post was edited on 3/30/16 at 10:30 am
Posted by SlapahoeTribe
Tiger Nation
Member since Jul 2012
12263 posts
Posted on 3/30/16 at 12:53 pm to
First, thanks for the help.

I took some time at lunch to look at it and using VBA I keep getting a blank cell? I copied the above function exactly.

Perhaps I'm doing something wrong. I don't have that much experience with VBA and have done almost no programming since undergrad years (pushing two decades).
Posted by msuhunter
Member since Aug 2014
5 posts
Posted on 3/30/16 at 12:57 pm to
send your email to msuhunter at yahoo . com and ill send you the file
Posted by SlapahoeTribe
Tiger Nation
Member since Jul 2012
12263 posts
Posted on 3/30/16 at 2:46 pm to
quote:

msuhunter



Working now, thanks a million!
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on X, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookXInstagram