mszekely
01-31-2017, 01:44 PM
I'm trying to cycle through a range of cells and merge all of the duplicates that are adjacent to one another (I know, merging cells is stupid but this is being required of me). It works for a few lines before returning an error. I'm not sure if it's the merged cells that's causing this. In my locals window, I have ACell = 0 when I first start to step in but it never changes to = 1 or = 2, it no longer returns an integer for me. Here's the code that's causing the issue (ACell is defined as range and FinalRow is defined as long):
Code:
Application.DisplayAlerts = False '<--- turns off the 'OK auto popup box'
For Each ACell In Range("d3:d" & FinalRow)
If ACell.Offset(1, 0).Value = "" Or ACell.Value = "" Then
' <---- if...then do nothing
Else
ACell.CurrentRegion.Columns(4).Merge
End If
Next
Application.displaylalerts = True
Any insights appreciated!
Code:
Application.DisplayAlerts = False '<--- turns off the 'OK auto popup box'
For Each ACell In Range("d3:d" & FinalRow)
If ACell.Offset(1, 0).Value = "" Or ACell.Value = "" Then
' <---- if...then do nothing
Else
ACell.CurrentRegion.Columns(4).Merge
End If
Next
Application.displaylalerts = True
Any insights appreciated!