Doflamingo
Board Regular
- Joined
- Apr 16, 2019
- Messages
- 238
Hi all,
I’m looking for the lines of code that would allow me to merge cells in column A where the number of cells merged in that column represent the number of items written in the column B.
Here is the code of the listbox 1 and listbox 2 that put items from those listboxes in the column B of an excel sheet
Here is the code of a previous thread that merge cells in column B where the number of cells merged in that column represent the number of items which have the same syntax written in the column A
Here is the thread: Merge cells by count vba
Does anyone have an idea about how to adapt those lines of code to a listbox from a userform ?
Many thanks in advance
I’m looking for the lines of code that would allow me to merge cells in column A where the number of cells merged in that column represent the number of items written in the column B.
Here is the code of the listbox 1 and listbox 2 that put items from those listboxes in the column B of an excel sheet
Code:
For b = 0 To ListBox1.ListCount - 1
With Sheets("Data")
nextRow = .Range("B" & Rows.Count).End(xlUp).Row + 1
.Range("B" & nextRow) = ListBox1.List(b)
End With
Next
For c = 0 To ListBox2.ListCount - 1
With Sheets("Data")
nextRow = .Range("B" & Rows.Count).End(xlUp).Row + 1
.Range("B" & nextRow) = ListBox2.List(c)
End With
Next
Here is the code of a previous thread that merge cells in column B where the number of cells merged in that column represent the number of items which have the same syntax written in the column A
Code:
Sub MergeBbasedonValinA()
Dim cellsA As Range
Dim i As Long
i = 1
For Each cellsA In Sheets("Sheet1").Range("A2:A50") 'expand range to your needs
If cellsA.Value <> cellsA.Offset(1, 0).Value Then
Range("B" & i & ":B" & cellsA.Row).Merge
i = cellsA.Row + 1
End If
Next cellsA
End Sub
Here is the thread: Merge cells by count vba
Does anyone have an idea about how to adapt those lines of code to a listbox from a userform ?
Many thanks in advance