how to separate a cell while also keeping the info in other columns the same?

ac1223

New Member
Joined
Jan 9, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
1704821022990.png


As shown above I need to know how you take one cell (the names) and split them all up while preserving the rest of the row without manually typing, copy and pasting everything.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Take a look at the Text To Columns feature on the ribbon?
 
Upvote 0
Sorry, I missed that. Your comment about preserving the rest of the row made me think of splitting into columns while not affecting the first part of the row.
 
Upvote 0
See if this does what you want:

Book1
AB
1TargetSarah,John,Steven
2WalmartMike,Kyle,Kevin
3
4TargetSarah
5TargetJohn
6TargetSteven
7WalmartMike
8WalmartKyle
9WalmartKevin
Sheet1


VBA Code:
Private Sub ArrayTestII()
Dim ws As Worksheet
Dim rngA As Range
Dim i, j, lRow&
Dim arrA As Variant
Dim collA As Object
Dim strA() As String

Set ws = Sheets("Sheet1")
lRow = ws.Range("A1").End(xlDown).Row
arrA = ws.Range("A1:B" & lRow).Value2
Set collA = CreateObject("System.Collections.ArrayList")

For i = 1 To UBound(arrA)
    strA = Split(arrA(i, 2), ",")
    For j = 0 To UBound(strA)
        collA.Add Join(Array(arrA(i, 1), strA(j)), ";")
    Next j
Next i

Set rngA = ws.[A4].Resize(collA.Count)

With rngA
    .Value = Application.Transpose(collA.toArray)
    .TextToColumns DataType:=xlDelimited, Semicolon:=True
End With

End Sub
 
Upvote 0
How about
Fluff.xlsm
ABCDE
1
2ax,y,zax
3bfay
4ch,jaz
5bf
6ch
7cj
Sheet8
Cell Formulas
RangeFormula
D2:E7D2=LET(c,LEN(B2:B4)-LEN(SUBSTITUTE(B2:B4,",",""))+1,HSTACK(TOCOL(IF(SEQUENCE(,MAX(c))<=c,A2:A4,1/0),2),DROP(REDUCE("",B2:B4,LAMBDA(x,y,VSTACK(x,TEXTSPLIT(y,,",")))),1)))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,107
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top