Merge cells containing the same information in multiple tables with macro
Hi everyone, I’m new to this and I’m trying to figure out how to do the following.
I have an excel file, the first sheet is the main table and from this table different subtables are formed and each table is on a different sheet.
For a better visualization of the data, the user needs to see these excel tables with the records grouped together.
All tables have the same columns only their data changes.
As you can see in the first image the table has each record separated in each row but the user wants to view it like the second image in which the table is merged in the records that contain the same information.
I already tried to do this in power automate with an office script connector but I couldn’t get it to work and the macro I have is the following, but it only does this merge in the range of cells that I specify and only in a single table.
Sub MergeSameCell()
Set myRange=(“DataDesk”)
MergeSame:
For Each Cell In myRange
If cell.Value = cell.Offset(1, 0).Value And Not IsEmpty(cell) Then
Range(cell, cell.Offset(1, 0)).Merge
cell.VerticalAlignment = xlCenter
GoTo MergeSame
End If
Next cell
End Sub
I would greatly appreciate your help.
Hi everyone, I’m new to this and I’m trying to figure out how to do the following.I have an excel file, the first sheet is the main table and from this table different subtables are formed and each table is on a different sheet.For a better visualization of the data, the user needs to see these excel tables with the records grouped together.All tables have the same columns only their data changes.As you can see in the first image the table has each record separated in each row but the user wants to view it like the second image in which the table is merged in the records that contain the same information. I already tried to do this in power automate with an office script connector but I couldn’t get it to work and the macro I have is the following, but it only does this merge in the range of cells that I specify and only in a single table.Sub MergeSameCell()
Set myRange=(“DataDesk”)
MergeSame:
For Each Cell In myRange
If cell.Value = cell.Offset(1, 0).Value And Not IsEmpty(cell) Then
Range(cell, cell.Offset(1, 0)).Merge
cell.VerticalAlignment = xlCenter
GoTo MergeSame
End If
Next cell
End SubI would greatly appreciate your help. Read More