View Single Post
  #24   Report Post  
Posted to microsoft.public.excel.programming
KH_GS[_11_] KH_GS[_11_] is offline
external usenet poster
 
Posts: 1
Default Extracting word from phrase within column


Hi NickHK

You r right on that, there is indeed further plans of expansion :cool


Regarding the code that you input earlier, I need some help.

Column A Column B
apple green and red 1
apple blue and green 2
red green blue 3

Output:
apple 1
green 1
and 1
red 1
apple 2
blue 2
and 2
green 2
red 3
green 3
blue 3

How can I input value of column B to a column beside the row of word
that will be generated by the code below?





Code
-------------------
Sub PrintWords()
Dim Cell As Range
Dim Words As Variant
Dim i As Long

x = ActiveCell.Row
y = ActiveCell.Column

'For Each Cell In Range(Selection, Selection.End(xlDown))
For Each Cell In Range(Range("A2"), Range("A2").End(xlDown))
Words = Split(Cell.Value, " ")
For i = 0 To UBound(Words)
Debug.Print Words(i)
'Or do what you want with the word

ActiveSheet.Cells(x, y).Value = Words(i)

x = x + 1


Next
Next

End Su
-------------------

--
KH_G
-----------------------------------------------------------------------
KH_GS's Profile: http://www.excelforum.com/member.php...fo&userid=3292
View this thread: http://www.excelforum.com/showthread.php?threadid=52741