I have a routine that merges sequential cells in column A. I need to merge the cells in column B that are sequentially matching, but NOT merge across the row boundaries of the merged column A cells. My merge for column A is working as expected.
However, if the values in column B have sequential values that begin next to merged A cell and continue into the next cell, they merge across the boundary. How do I base my merger of sequentially matching B cells on the already merged A cells?
Here's how my code currently merges the row boundaries of column A's merged cells:
Here's how I intend for it to look:
My current code:
Sub MergeV()
' Merge Administration and Category where sequentional matching rows exist
' Turn off screen updating
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Current As Worksheet
Dim lrow As Long
For Each Current In ActiveWorkbook.Worksheets
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Set rngMerge = Current.Range("A2:B" & lrow)
MergeAgain:
For Each cell In rngMerge
If cell.Value = cell.Offset(1, 0).Value And IsEmpty(cell) = False Then
Range(cell, cell.Offset(1, 0)).Merge
GoTo MergeAgain
End If
Next
Next Current
' Turn screen updating back on
Application.Calculation = xlCalculationAutomatic
End Sub
Any guidance on accomplishing this would be greatly appreciated!
ScreenUpdating
andDisplayAlerts
back "on" by setting them back toTrue
followingApplication.Calculation
– Marcucciboy2ScreenUpdating
to True automatically, but as to me I prefer to state it explicitly. – JohnyL