A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Try this - https://1drv.ms/u/s!AldvjX7HG_m7gVntcWUttbDCCl5...
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Table AccessDownload (A1:H172) Merge cells where dates are the same and if description is closing Balance
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Here is the macro. File can be downloaded from https://1drv.ms/x/s!AldvjX7HG_m7gUYczQqCHoInx2p...
Option Explicit
Sub MergeCells()
Dim LastRow As Long, i As Long, j As Long, k As Long
Dim Ws As Worksheet
Set Ws = ActiveSheet
LastRow = Ws.Cells(Rows.Count, 1).End(xlUp).Row
'If there is no data, leave Sub
If LastRow <= 2 Then
MsgBox "Sheet has no data"
Exit Sub
End If
Application.ScreenUpdating = False
Application.DisplayAlerts = False
j = 1
For i = 3 To LastRow
With Ws
If .Cells(i, "A") = .Cells(i - 1, "A") Then
If .Cells(i, "B") = .Cells(i - 1, "B") And .Cells(i, "B") = "Closing Balance" Then
If j = 1 Then
k = i - 1
End If
j = j + 1
End If
Else
If j >= 2 Then
.Cells(k, "A").Resize(j).Merge
.Cells(k, "B").Resize(j).Merge
j = 1
End If
End If
End With
Next i
ExitSub:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Closing Balance have to be included for row 119 only
Rows 17 and 18 remains as is
Income Paid 0.0 for both and Grand Total row 17 $137,495.00
Grand Total row 18 $ 244,338.65
I have a doubt, you have highlighted many cells in pink even though description is not Closing Balance.
Do I need to ignore Closing Balance logic?
Also see row numbers 17 and 18 where dates are same but descriptions are different.