• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need to copy specific text from one cell to another when source cell has returns

Mike Wyller

New Member
I have a file where a particular cell has 5 attributes listed.
What I'm trying to do is copy each attribute from that cell, to 5 different cells.
Source data looks like this:
Cell G3 contains the following data (with returns after each line)
Applicable: Yes
Required: No
Repeating: No
Default Value: New
Business Rules: Cannot Proceed without selecting one of the radio buttons​

I have 5 new columns to the right of this cell, titled
"Applicable" "Required" "Repeating" "Default Value" "Business Rules"
I would like to add
'Yes' to the "Applicable" column (H3),
'No' to the "Required" column (I3),
'No' to the "Repeating" column (J3),
'New' to the "Default Value" column (K3),
'Cannot Proceed without selecting one of the radio buttons' to the "Business Rules" column (L3)​

I've tried variations of LEFT, RIGHT, MID, FIND etc. but can't get it to work.
Any ideas?
 
Paste in a Module. Add formula array as commented.
Code:
'=IFERROR(ParseR(G3),""), select number of columns to parse to and press Alt+Ctrl+Enter to enter as forumula array.
Function ParseR(aCell As Range, Optional delimit As String = vbLf)
  Dim icols As Integer, i As Integer, j As Integer, a, b
  a = Split(aCell, delimit)
  icols = UBound(a)
  ReDim b(0 To icols)
  For i = 0 To UBound(a)
    b(i) = ""
  Next i
  On Error GoTo EndNow
  For i = 0 To UBound(a)
    b(i) = Split(a(i), ": ")(1)
  Next i
  ParseR = b  'WorksheetFunction.Transpose(b)
EndNow:
End Function
 
Back
Top