View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2017_] Rick Rothstein \(MVP - VB\)[_2017_] is offline
external usenet poster
 
Posts: 1
Default extracting strings from cell

I am assuming that when you say the cell contains
"AAA BBB CCC DDD", you mean without the surrounding quote marks. Give
this code snippet a try...

Dim Names() As String
With Worksheets("Sheet1")
Names = Split(.Range("A1").Value, " ")
End With

' Proof that it worked
Dim X As Long
For X = 0 To UBound(Names)
Debug.Print Names(X)
Next

Change the Sheet1 and A1 references to match your needs.

Rick


"Anand" wrote in message
...
I have multiple names stored in a cell. I want to extract individual
names out of the cell. Appreciate any help in this regard.

The cell contains "AAA BBB CCC DDD"
I want to extract this into an array:
Names(0) = "AAA"
Names(1) = "BBB"
Names(2) = "CCC"
Names(3) = "DDD"

Thanks,
Anand.