john316swan
Board Regular
- Joined
- Oct 13, 2016
- Messages
- 66
- Office Version
- 2019
- Platform
- Windows
I have a pivot table with data:
<tbody>
</tbody>
I am trying to write a function (combine docs) that combines all documents in 1 string
I found this code online that I modified but I can't figure out how to have the column header value displayed:
Thanks for your help!
Doc 1 | doc 2 | doc 3 | doc 4 | combine docs |
1 | 1 | Doc 1,Doc 3 (=combineDocs(A2:A4)) | ||
1 | 1 | Doc 2,Doc 3 (=combineDocs(B2:B4)) |
<tbody>
</tbody>
I am trying to write a function (combine docs) that combines all documents in 1 string
I found this code online that I modified but I can't figure out how to have the column header value displayed:
Code:
Function combineDocs(workRng As Range, Optional Sign As String = ",") As String
Dim r As Range
Dim OutStr As String
For Each r In workRng
If r.Text <> "" Then
OutStr = OutStr & Cells(2, Left(r, 1)).Text & Sign 'note my column header is on row 2
End If
Next
combineDocs = Left(OutStr, Len(OutStr) - 1)
End Function
Thanks for your help!