Consolidate rows in Excel sheet and show as comma separated - excel

I have the data in excel as below where combination of Column A and Column C makes a unique combination. As we can see there are duplicate rows(considering Column A & C). How can I consolidate the rows based on Column A & C and show row B as comma separated. Column A is sorted in my current sheet.
I have seen the question here which is similar but it is considering the unique values based on only 1 column.
I want the data to be represented as below. Is this possible?

Very easy with Power Query, available in Excel 2010+
In this case, all can be done from the User Interface.
Select some cell in the table
Data --> Get & Transform --> From Table/Range
Select the Parent Product and Product columns and Group By
Operation:= All Rows
Add Custom Column
Formula: =Table.Column([Grouped],"Sequence")
New Column Name: Sequence
Select the double headed arrow at the top of the Sequence Column
Extract values with comma separated
Delete the extra columns and rearrange.
M-Code
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent Product", type text}, {"Sequence", type any}, {"Product", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Parent Product", "Product"}, {{"Grouped", each _, type table [Parent Product=text, Sequence=anynonnull, Product=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Sequence", each Table.Column([Grouped],"Sequence")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Sequence", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Reordered Columns" = Table.ReorderColumns(#"Extracted Values",{"Parent Product", "Sequence", "Product", "Grouped"}),
#"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Grouped"})
in
#"Removed Columns"

If you are after formulas, and you got Excel O365, you could try:
Formula in E2, dragged down:
=INDEX(A:A,MATCH(G2,C:C,0))
Formula in F2, dragged down:
=TEXTJOIN(",",,FILTER(B2:B9,C2:C9=G2))
Formula in G2:
=UNIQUE(C2:C9)
Though I'm pretty sure this can be done through PowerQuery avoiding formulas and VBA alltogether.

Here's VBA based approach.
Public Sub BuildConsolidatedList()
Dim srcWks As Worksheet, dstWks As Worksheet
Dim objDict As Object
Dim i As Long
Dim k
Set srcWks = ThisWorkbook.Sheets("Sheet1") '\\ Define Source Sheet Here
Set dstWks = ThisWorkbook.Sheets("Sheet2") '\\ Define Destination Sheet Here
Set objDict = CreateObject("Scripting.Dictionary")
objDict.CompareMode = vbTextCompare
For i = 2 To srcWks.Range("A" & srcWks.Rows.Count).End(xlUp).Row '\\ Loop through Source Data and build up unique entries
If objDict.Exists(srcWks.Range("A" & i).Value & "|" & srcWks.Range("C" & i).Value) Then
objDict.Item(srcWks.Range("A" & i).Value & "|" & srcWks.Range("C" & i).Value) = _
objDict.Item(srcWks.Range("A" & i).Value & "|" & srcWks.Range("C" & i).Value) & "," & srcWks.Range("B" & i).Value
Else
objDict.Add srcWks.Range("A" & i).Value & "|" & srcWks.Range("C" & i).Value, srcWks.Range("B" & i).Value
End If
Next i
i = 2 '\\ Destination sheet start row
For Each k In objDict.Keys '\\ Loop through all values in dictionary object
dstWks.Range("A" & i).Value = Split(k, "|")(0)
dstWks.Range("B" & i).Value = objDict.Item(k)
dstWks.Range("C" & i).Value = Split(k, "|")(1)
i = i + 1
Next k
End Sub

Related

Excel: Multiple rows with the same ID, add column for different variables

I have a file excel (simplified below) with multiple rows with the same ID, the reson why i have multiple rows is because some field are different but i need only one row for each ID.
I have tried to solve this problem using transpose but it does not take into account when the ID is the same, also i have tried so create an IF in each column but it does not work.
Example:
Result:
I solved the problem using this macro:
Sub Consolidate_Rows()
Dim xRg As Range
Dim xRows As Long
Dim I As Long, J As Long, K As Long
On Error Resume Next
Set xRg = Application.InputBox("Select Range:", "Kutools For Excel", Selection.Address, , , , , 8)
Set xRg = Range(Intersect(xRg, ActiveSheet.UsedRange).Address)
If xRg Is Nothing Then Exit Sub
xRows = xRg.Rows.Count
For I = xRows To 2 Step -1
For J = 1 To I - 1
If xRg(I, 1).Value = xRg(J, 1).Value And J <> I Then
For K = 2 To xRg.Columns.Count
If xRg(J, K).Value <> "" Then
If xRg(I, K).Value = "" Then
xRg(I, K) = xRg(J, K).Value
Else
xRg(I, K) = xRg(I, K).Value & "," & xRg(J, K).Value
End If
End If
Next
xRg(J, 1).EntireRow.Delete
I = I - 1
J = J - 1
End If
Next
Next
ActiveSheet.UsedRange.Columns.AutoFit
End Sub
Please refer this, you can easily transform the data, as you are expecting using both Excel Formula as well as using Power Query
Approach Using Excel Formula --> Applicable to Excel 2021 & O365 Users
Formula used in cell A15
=UNIQUE(A2:E5)
Formula used in cell F15
=TRANSPOSE(FILTER($F$2:$F$5,A15=$A$2:$A$5))
Approach Using Power Query
Select the data and from Data Tab, Under Get & Transform Data Group, Click From Table/Range
On Clicking above you shall be prompted with Create Table window, click the check box on my table as headers and press ok
On doing above you shall be directed to power query editor
Select the first 5 columns by holding down the shift key and press Group By from Home Tab, under Transform group or From Transform tab
A new window opens as shown below, enter the new column name as All, and the Operation will All Rows press Ok
Next from Add Column Tab --> Click Custom Column and enter the below in custom column formula, and name new column name as Provincia
Table.Column([All],"Provincia")
Click on the dropdown from the Provincia column and select extract values, press Ok
Now again select the column Provincia and Click on Split Column From Home Tab, delimiter is comma, split at each occurrence of the delimiter and press ok, refer the image below
Once the column is split it shall show like below, and now remove the unwanted column All
Last but not least from Home Tab, Click Close & Load To
From Import Data Window --> Select Table, you can check Existing worksheet or New worksheet, if checking Existing worksheet then select the cell where you want to place the data
Expected Output as desired, this is one time process, and whenever you add new data just refresh the imported data, it updated within in few, you are not hardcoding anything here with just few simple steps, its done,
You can also paste this M-Language only change the Table Name as per your workbook
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"ID", "Targa", "Modello", "Lordo Chiusura", "Lordo Apertura"}, {{"All", each _, type table [ID=text, Targa=text, Modello=text, Lordo Chiusura=text, Lordo Apertura=text, Provincia=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Provincia", each Table.Column([All],"Provincia")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Provincia", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Provincia", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Provincia.1", "Provincia.2", "Provincia.3", "Provincia.4"}),
#"Removed Columns" = Table.RemoveColumns(#"Split Column by Delimiter",{"All"})
in
#"Removed Columns"

Sum column values based on condition

I'm an intern and I've been struggling to find a solution since this monday...
I'm new to VBA and I don't clearly see how I can sum cells from a column based on some conditions..I tried multiple code but as soon as my codes didnt work I deleted them.
So what I'm trying to do is the following;
I've got a worksheet called worksheets("Amounts") in which I've got a data base.
What I've been struggling to do since this Monday :
Sum the amounts value in column Q ( "AMOUNT") Only if rows of COL A, col B, col C, col , col E, col F have equivalent cells value.
Then, I'd like to sum in col Q the amounts based on the previous condition and put the total in one single row in the place of the rows that contain common values.
Right after I'd like to delete each rows that were matching to one another to display the agregated amount with the common values. Like the following example;
My data base;
COL A
COL B
COL C
COL E
COL F
COL Q
CODE
STATUE
ATTRIBUTE
Country
Capital
AMOUNT
A1
OK
Z1
ENGLAND
LONDON
400
C1
NOK
R2
SPAIN
MADRID
50
A1
OK
Z1
ENGLAND
LONDON
300
D1
PENDING
X
CANADA
OTTAWA
10
the Output expected;
COL A
COL B
COL C
COL E
COL F
COL Q
CODE
STATUE
ATTRIBUTE
Country
Capital
AMOUNT
A1
OK
Z1
ENGLAND
LONDON
700
C1
NOK
R2
SPAIN
MADRID
50
D1
PENDING
X
CANADA
OTTAWA
10
==> So here we have only 2 rows with common value on col A, B, C, E and F. I'd like to sum the amounts of these two rows and delete these two rows to make a single one with these common values like the up-above example.
Obviously for the other rows that dont match with other rows I'd like to let them as they were.
the database in worksheets("Amount") can vary and can get more or less rows, so I will need to automatize this process.
Here is my last saved code:
Option Explicit
Sub agreg()
Dim i As Long
Dim ran1 As Range
ran1 = ThisWorkbook.Worksheets("Values").Range("A" & Worksheets("Values").Rows.Count).End(xlUp).row + 1
For Each i In ran1
If Cells(i, 1) = Range("A1", Range("A1").End(xlDown)).Value Then
cells(i,4) + range("D1",range("D1").End(xlDown)).Value
End If
Next i
End Sub ```
Please, test the next code:
Sub SumUnique5Cols()
Dim sh As Worksheet, lastRow As Long, arr, arrQ, rngDel As Range, i As Long, dict As Object
Set sh = Worksheets("Amounts")
lastRow = sh.Range("A" & sh.rows.count).End(xlUp).row 'last row based on A:A column
arr = sh.Range("A2:Q" & lastRow).Value2 'place the range in an array to make the code faster
Set dict = CreateObject("Scripting.Dictionary") 'set a dictionary to keep the unique keys combination value
For i = 1 To UBound(arr) 'iterate between the array elements
If Not dict.Exists(arr(i, 1) & arr(i, 2) & arr(i, 3) & arr(i, 5) & arr(i, 6)) Then 'if the combination key does not exist:
dict.Add arr(i, 1) & arr(i, 2) & arr(i, 3) & arr(i, 5) & arr(i, 6), arr(i, 17) 'it is created (and take the value of Q:Q cell)
Else 'if the key aleready exists, it adds the value in the key item:
dict(arr(i, 1) & arr(i, 2) & arr(i, 3) & arr(i, 5) & arr(i, 6)) = dict(arr(i, 1) & arr(i, 2) & arr(i, 3) & arr(i, 5) & arr(i, 6)) + arr(i, 17)
'range of the rows to be deleted is filled in this way:
If rngDel Is Nothing Then
Set rngDel = sh.Range("A" & i + 1) 'if the range does not exist, it is set (i + 1, because of iteration starting from the second row)
Else
Set rngDel = Union(rngDel, sh.Range("A" & i + 1)) 'if it exists, a union between the previus range and the new one is created
End If
End If
Next i
If Not rngDel Is Nothing Then rngDel.EntireRow.Delete 'if there are rows to be deleted, they are deleted
lastRow = sh.Range("A" & sh.rows.count).End(xlUp).row 'recalculate the last row (after rows deletion)
arr = sh.Range("A2:Q" & lastRow).Value2 'place the remained range in an array
ReDim arrQ(1 To UBound(arr), 1 To 1) 'ReDim the final array (to keep the summ) according to the remained rows
For i = 1 To UBound(arr)
arrQ(i, 1) = dict(arr(i, 1) & arr(i, 2) & arr(i, 3) & arr(i, 5) & arr(i, 6)) 'put in the array the corresponind dictionary key value
Next i
sh.Range("Q2").Resize(UBound(arrQ), 1).value = arrQ 'drop the array content at once
End Sub
In Power Query it would be simple:
Group by those columns
Aggregate by the Sum of Amount
Power Query is available in Windows Excel 2010+ and Office 365
To use Power Query
Select some cell in your Data Table
Data => Get&Transform => from Table/Range
When the PQ Editor opens: Home => Advanced Editor
Make note of the Table Name in Line 2
Paste the M Code below in place of what you see
Change the Table name in line 2 back to what was generated originally.
Read the comments and explore the Applied Steps to understand the algorithm
M Code
let
//Change table name in next line to actual table name in the workbook
Source = Excel.CurrentWorkbook(){[Name="Table10"]}[Content],
//set data types
//note the columns named ColumnN which will be different with your real data
#"Changed Type" = Table.TransformColumnTypes(Source,{
{"CODE", type text},
{"STATUE", type text},
{"ATTRIBUTE", type text},
{"Column1", type any},
{"Country", type text},
{"Capital", type text},
{"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}, {"Column11", type any},
{"Amount", Int64.Type}}),
//group by columns 1,2,3,5,6
//return Sum of the Amount Column
#"Grouped Rows" = Table.Group(#"Changed Type", {"CODE", "STATUE", "ATTRIBUTE", "Country", "Capital"},
{{"Amount", each List.Sum([Amount]), type nullable number}})
in
#"Grouped Rows"
Data
Results
If you want to do it with VBA I would use ADODB to group the rows
Public Sub SumGroup()
Dim connection As Object
Set connection = CreateObject("ADODB.Connection")
connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
Dim recordset As Object
Dim sSQL As String
sSQL = "SELECT Code, Statue, Attribute, Country, Capital, Sum(Amount) as SumAmount FROM [Database$] GROUP BY Code, Statue, Attribute, Country, Capital"
Set recordset = connection.Execute(sSQL)
Worksheets("Result").Range("A1").CopyFromRecordset recordset
recordset.Close
connection.Close
End Sub
The data should be in a sheet with the name Database. The result will be written to a sheet with the name Result. Both sheets should exist in the workbook before running the code.
A Pivottable would give you what you want without any coding nor in VBA or M

Restructure Excel table with VBA

I have an Excel table source (extract is below):
Models are changing (adding new names, removing), so does change Week number in Columns (from Now till end of the year)
I need to restructure it so that it could look like this:
So that it could be normally used for further querying.
In each row there must be model name, for each model there should be Week number and corresponding matching Quantity taken from the table itself (on the intersection of Model X Week from original table).
I was smashing my head against the wall on how it can be realized in VBA. Couldn't restructure it with simple code.
try this code, just change the name of your sheets I used 2, the first is the source and the second is the destination, I hope help you
good Luck
Sub RestructureTable()
Const SourceSheetName = "Source", DestinationSheetName = "Restructure" 'Your sheet names
Dim nRowCounter As Double, nColumnSourceCounter As Double, nRowSourceCounter As Double
'--------
'-------Set the headers in destination sheet
Sheets(DestinationSheetName).Range("A1") = "Models" 'Replace "Models" as you need
Sheets(DestinationSheetName).Range("B1") = "Week" 'Replace "Week" as you need
Sheets(DestinationSheetName).Range("C1") = "Qty" 'Replace "Qty" as you need
'--------
'----------------------------------------------------
Sheets(SourceSheetName).Select 'Select the source sheet
Range("A2").Select ' select the first cell with data
nRowCounter = 2 ' Start in 2 cuase headers
'---------------------------------------------------
nRowSourceCounter = ThisWorkbook.Application.WorksheetFunction.CountA(Range("A:A")) 'count rows
nColumnSourceCounter = ThisWorkbook.Application.WorksheetFunction.CountA(Range("1:1")) 'count columns
For r = 2 To nRowSourceCounter
For c = 2 To nColumnSourceCounter
'Model
Sheets(DestinationSheetName).Range("A" & nRowCounter) = Sheets(SourceSheetName).Cells(r, 1)
'Header:Week
Sheets(DestinationSheetName).Range("B" & nRowCounter) = Sheets(SourceSheetName).Cells(1, c)
'Qty
Sheets(DestinationSheetName).Range("C" & nRowCounter) = Sheets(SourceSheetName).Cells(r, c)
nRowCounter = nRowCounter + 1
Next c
Next r
End Sub
You could do this with VBA but you could also do it with only a few steps using Power Query.
VBA Method
Here's code to do it with VBA, it assumes the data to restructure is in a sheet named Data and starts at A1.
In this code the restructured data is put on a new sheet but you could change that to put it on an existing sheet.
Option Explicit
Sub RestructureData()
Dim ws As Worksheet
Dim arrDataIn As Variant
Dim arrDataOut() As Variant
Dim cnt As Long
Dim idxCol As Long
Dim idxRow As Long
arrDataIn = Sheets("Data").Range("A1").CurrentRegion.Value
ReDim arrDataOut(1 To (UBound(arrDataIn, 1) - 1) * (UBound(arrDataIn, 2) - 1), 1 To 3)
For idxRow = LBound(arrDataIn, 1) + 1 To UBound(arrDataIn, 1)
For idxCol = LBound(arrDataIn, 2) + 1 To UBound(arrDataIn, 2)
cnt = cnt + 1
arrDataOut(cnt, 1) = arrDataIn(idxRow, 1)
arrDataOut(cnt, 2) = arrDataIn(1, idxCol)
arrDataOut(cnt, 3) = arrDataIn(idxRow, idxCol)
Next idxCol
Next idxRow
Set ws = Sheets.Add ' can be set to existing worksheet
ws.Range("A1:C1").Value = Array("Model", "Week", "Quantity")
ws.Range("A2").Resize(cnt, 3).Value = arrDataOut
End Sub
Power Query Method
Go to the sheet with the data, then go to the Data>Get & Transform Data tab.
Select From Table/Range, make sure all the data is selected and Does your data have headers? is ticked.
In Power Query select the Model column, right click and select Unpivot Other Columns.
Rename the Attribute column 'Week' and the value column 'Quantity' by double click each column header.
Click Close & Load to return the data to Excel.
This is the M Code those steps produce.
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Models", type text}, {"2021-03-29_(W13)", Int64.Type}, {"2021-04-05_(W14)", Int64.Type}, {"2021-04-12_(W15)", Int64.Type}, {"2021-04-19_(W16)", Int64.Type}, {"2021-04-26_(W17)", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Models"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Week"}, {"Value", "Quantity"}})
in
#"Renamed Columns"

How to combine 2 VBA functions based on condition of 1 function?

I have a dataset where contact information and names are correlated to companies that the individual has worked for. 1 individual can be associated with many companies. I want to consolidate information of the individuals but keep information on the different company names.
I have a VBA function that can remove duplicates of rows (name and contact info) and another VBA function that can merge two separate cells (company names) into 1 merged cell. The data isn't sorted by any particular field.
I would like to create a function that will remove duplicates of rows AND THEN merge the company name cells BUT ONLY FOR individuals that have duplicate rows removed (meaning that the individual is associated with more than 1 company).
Thanks for any help!
Sample of raw data format:
this is the function and result of VBA function 1:
Sub RemoveDuplicates()
'UpdatebyExtendoffice20160918
Dim xRow As Long
Dim xCol As Long
Dim xrg As Range
Dim xl As Long
On Error Resume Next
Set xrg = Application.InputBox("Select a range:", "Kutools for Excel", _
ActiveWindow.RangeSelection.AddressLocal, , , , , 8)
xRow = xrg.Rows.Count + xrg.Row - 1
xCol = xrg.Column
'MsgBox xRow & ":" & xCol
Application.ScreenUpdating = False
For xl = xRow To 2 Step -1
If Cells(xl, xCol) = Cells(xl - 1, xCol) Then
Cells(xl, xCol) = ""
End If
Next xl
Application.ScreenUpdating = True
End Sub
Function 2 is below and the module just concatenates and merges cells, but I don't know how to write a function that will only apply where the individual has had duplicate rows removed (meaning that individual is associated with multiple companies).
Sub MergeCells()
Dim xJoinRange As Range
Dim xDestination As Range
Set xJoinRange = Application.InputBox(prompt:="Highlight source cells to merge", Type:=8)
Set xDestination = Application.InputBox(prompt:="Highlight destination cell", Type:=8)
temp = ""
For Each Rng In xJoinRange
temp = temp & Rng.Value & " "
Next
xDestination.Value = temp
End Sub
I would approach this differently and use Power Query, available in Excel 2010+.
Power Query as a "Group By" method where you can select the columns you want to group by -- in your case it would be all the columns except the Company column. You can then concatentate the company column using linefeeds, and obtain the result you desire.
Data --> Get & Transform Data --> From Table/Range
Select all the columns except Company and Group By
The Operation is All Rows
Add Custom Column (to split out the company names with formula:
Table.Column([Grouped],"Company")
Select the Double-headed arrow at the top of the custom column
Extract values from list
Use the line feed for the separator #(lf)
Close and Load to
You may have to do some custom formatting for the phone number, and also set Word Wrap for the company column.
Here is the generated MCode:
let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Email", type text}, {"Phone", Int64.Type}, {"First Name", type text}, {"Last Name", type text}, {"Company", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Email", "Phone", "First Name", "Last Name"}, {{"Grouped", each _, type table [Email=text, Phone=number, First Name=text, Last Name=text, Company=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Company", each Table.Column([Grouped],"Company")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Company", each Text.Combine(List.Transform(_, Text.From), "#(lf)"), type text})
in
#"Extracted Values"
And here are the results:

Excel Split cell with multiple lines into rows for entire table

In Excel (2016), I have some data that looks like this:
Based on a particular column, in this example the 'IPAddress' column, if there are multiple lines in the cell, separate the string into a new row and copy the remaining data into that row.
This is what I am looking for after the script or whatever completes.
I'm using the follow code from: Split cell with multiple lines into rows
Sub tes_5()
Dim cell_value As Variant
Dim counter As Integer
'Row counter
counter = 1
'Looping trough A column define max value
For i = 1 To 10
'Take cell at the time
cell_value = ThisWorkbook.ActiveSheet.Cells(i, 1).Value
'Split cell contents
Dim WrdArray() As String
WrdArray() = Split(cell_value, vbLf)
'Place values to the B column
For Each Item In WrdArray
ThisWorkbook.ActiveSheet.Cells(counter, 2).Value = Item
counter = counter + 1
Next Item
Next i
End Sub
That separates out the IPAddress column, but does not add the data for the other cells in the new row.
Text to columns doesn't work and Power Query (https://www.quora.com/Is-there-a-way-in-excel-to-bulk-split-cells-with-multiple-lines-inside-into-new-rows-without-overwriting-the-existing-data-below) doesn't work either.
Any other suggestions?
Update:
Just learned that by default, Excel puts a comma at the beginning of the delimiter field, which was causing my delimiter to not work when choosing line feed.
If you remove the leading comma, you "should" (like I did), get the desired results.
Pretty simple with Power Query
All you need to do is split the IPAddress column by the linefeed character into Rows
Split Column dialog from UI
M-Code
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Server Name", type text}, {"Serial Number", type text}, {"OS", type text}, {"IPAddress", type text}}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"IPAddress", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "IPAddress")
in
#"Split Column by Delimiter"
Try this, assuming your data starts in A2:
Sub x()
Dim r As Long, v As Variant
For r = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
v = Split(Cells(r, 4), vbLf)
If UBound(v) > 0 Then
Cells(r + 1, 1).Resize(UBound(v), 4).Insert shift:=xlDown
Cells(r + 1, 1).Resize(UBound(v), 3).Value = Cells(r, 1).Resize(, 3).Value
Cells(r, 4).Resize(UBound(v) + 1).Value = Application.Transpose(v)
End If
Next r
End Sub

Resources