cwb1021
03-18-2017, 09:03 AM
Hello Experts,
Im attempting to write a procedure that will merge the common values in a column to a single cell. In the picture here I have shown the data set in column A and the desired results in column B.
18674
Below is where I've started. I'm not sure if im going about this the right way and my syntax is off. I've also attached the worksheet.
Sub MarkerMerge()
Dim MarkerRange As Range, cell As Range
Dim wsS1 As Worksheet
Sect wsS1 = Worksheets("Sheet1")
Set MarkerRange = Intersect(wsS.Columns(1), wsS.UsedRange)
For Each cell In MarkerRange
If cell.Value = cell.Offset(-1, 0) Then
ActiveCell.Select
ActiveCell.Offset(-1, 0).Select
Range(ActiveCell.Address, ActiveCell.End(xlUp)).Select
With Selection
.Merge
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
End If
Next cell
End Sub
Alternatively, I could use a worksheet function to populate column B with arguments from column A.
Any help is greatly appreciated!
Thanks,
Chris
Im attempting to write a procedure that will merge the common values in a column to a single cell. In the picture here I have shown the data set in column A and the desired results in column B.
18674
Below is where I've started. I'm not sure if im going about this the right way and my syntax is off. I've also attached the worksheet.
Sub MarkerMerge()
Dim MarkerRange As Range, cell As Range
Dim wsS1 As Worksheet
Sect wsS1 = Worksheets("Sheet1")
Set MarkerRange = Intersect(wsS.Columns(1), wsS.UsedRange)
For Each cell In MarkerRange
If cell.Value = cell.Offset(-1, 0) Then
ActiveCell.Select
ActiveCell.Offset(-1, 0).Select
Range(ActiveCell.Address, ActiveCell.End(xlUp)).Select
With Selection
.Merge
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
End If
Next cell
End Sub
Alternatively, I could use a worksheet function to populate column B with arguments from column A.
Any help is greatly appreciated!
Thanks,
Chris