Hello. I have a VBA code to merge multiple rows based on like values . Below is an excerpt of the raw data (1st Image). My data range is actually Columns A through H, but that doesn't seem relevant to my question. My code will do exactly what I want except when I have the Job Duty Percentage of a Job Duty Number equal to the Job Duty Percentage of a different Job Duty Number. Job Duty Number 2 and Job Duty Number 3 are both 20 percent each of the total. When my code runs it looks like 2md Image below. How can I modify my code that the 20 % shows next to each Job Duty Description instead of the 20 showing as a shared value?
?
1st Image.
2nd Image.
VBA Code:
Option Explicit
Sub Merge_Same_Cells()
Application.DisplayAlerts = False
Dim rng As Range
Worksheets("RawData").Range("A6:H1500").Select
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
1st Image.
2nd Image.