Hello, I am trying to compare the value of a set of cells (rows 85 to 200 of column 5), so that if they have the same value the cells get merged. I have tried this code but it doesn't work. This is part of a code that exports some queries using CopyFromRecordest, so this loop is inside the corresponding "with xlSheet".
Could someone give me a hand?
Thanks a lot
Code:
For nrow = 85 To 200
If .Cells(nrow, 5) <> .Cells(nrow + 1, 5) Then
With .Range(.Cells(nrow, 5) & "," & .Cells(nrow + 1, 5))
.Merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
nrow = nrow + 1
End If
Next nrow
Could someone give me a hand?
Thanks a lot