I need my code tweaked a little. Currently, I have to highlight Column B through I which hold the data to be merged and then run the macro. These columns will remain constant and not change. The number of rows will vary. I want the macro to contain code that will maintain columns B through I as the columns to merge so that I do not have to highlight those columns before running the macro. Appreciate any help on this I can get. Thanks.
VBA Code:
Option Explicit
Sub Merge_Same_Cells()
Application.DisplayAlerts = False
Dim rng As Range
MergeCells:
For Each rng In Selection
If rng.Value = rng.Offset(1, 0).Value And rng.Value <> "" Then
Range(rng, rng.Offset(1, 0)).Merge
Range(rng, rng.Offset(1, 0)).HorizontalAlignment = xlCenter
Range(rng, rng.Offset(1, 0)).VerticalAlignment = xlCenter
GoTo MergeCells
End If
Next