I have read many discussions on how to CONCATENATE or not to. Using public functions or entering the data in active cell.
Right now I want it to select range D2 and combine all data in column D (not including blanks or duplicates) into Cell D2 with a delimiter (/)
Range("D2").Select
ActiveCell.FormulaR1C1 =
Raw Data
[TABLE="class: grid, width: 133"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: center"]Column D
[/TD]
[/TR]
[TR]
[TD="align: center"]Line
[/TD]
[/TR]
[TR]
[TD="align: center"]10
[/TD]
[/TR]
[TR]
[TD="align: center"]30[/TD]
[/TR]
[TR]
[TD="align: center"]50[/TD]
[/TR]
[TR]
[TD="align: center"]50
[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
</tbody>[/TABLE]
Fixed Data
[TABLE="class: grid, width: 133"]
<tbody>[TR]
[TD="align: center"]Column D
[/TD]
[/TR]
[TR]
[TD="align: center"]Line
[/TD]
[/TR]
[TR]
[TD="align: center"]10/30/50/70
[/TD]
[/TR]
[TR]
[TD="align: center"]30[/TD]
[/TR]
[TR]
[TD="align: center"]50[/TD]
[/TR]
[TR]
[TD="align: center"]50
[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
</tbody>[/TABLE]
I tried applying the below function with no luck.
Right now I want it to select range D2 and combine all data in column D (not including blanks or duplicates) into Cell D2 with a delimiter (/)
Range("D2").Select
ActiveCell.FormulaR1C1 =
Raw Data
[TABLE="class: grid, width: 133"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: center"]Column D
[/TD]
[/TR]
[TR]
[TD="align: center"]Line
[/TD]
[/TR]
[TR]
[TD="align: center"]10
[/TD]
[/TR]
[TR]
[TD="align: center"]30[/TD]
[/TR]
[TR]
[TD="align: center"]50[/TD]
[/TR]
[TR]
[TD="align: center"]50
[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
</tbody>[/TABLE]
Fixed Data
[TABLE="class: grid, width: 133"]
<tbody>[TR]
[TD="align: center"]Column D
[/TD]
[/TR]
[TR]
[TD="align: center"]Line
[/TD]
[/TR]
[TR]
[TD="align: center"]10/30/50/70
[/TD]
[/TR]
[TR]
[TD="align: center"]30[/TD]
[/TR]
[TR]
[TD="align: center"]50[/TD]
[/TR]
[TR]
[TD="align: center"]50
[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
[TR]
[TD="align: center"]70[/TD]
[/TR]
</tbody>[/TABLE]
I tried applying the below function with no luck.
Code:
Function ConcatenateRange(ByVal cell_range As Range, _
Optional ByVal seperator As String) As String
Dim cell As Range
Dim newString As String
Dim cellArray As Variant
Dim i As Long, j As Long
cellArray = cell_range.Value
For i = 1 To UBound(cellArray, 1)
For j = 1 To UBound(cellArray, 2)
If Len(cellArray(i, j)) <> 0 Then
newString = newString & (seperator & cellArray(i, j))
End If
Next
Next
If Len(newString) <> 0 Then
newString = Right$(newString, (Len(newString) - Len(seperator)))
End If
ConcatenateRange = newString
End Function