Hi all!
I'm trying to use TEXTJOIN in VBA. For the most part it's working but it's not joining everything. At first, I thought perhaps the format is incorrect. I made sure it was all text, but no luck. Looking at my result table, it's not consistent with the format that it joins. I don't think it's that.
or if you have a better idea, let me know!
Thanks in advance!
PS. I prefer using TEXTJOIN because of the delimiter and skipping blanks so that it doesn't add extra spaces, as CONCAT would do.
Data is below
Pgm: | ZPPR_INV_REFERRAL_SUMM | |
Tcode: | ZPPIRS | |
Date: | 02/08/2021 | |
Time: | 12:34:13 |
Blow is my result
RED: Data not joining
GREEN: Data joined
Pgm: | ZPPR_INV_REFERRAL_SUMM | |
Tcode: ZPPIRS | ZPPIRS | |
Date: | 02/08/2021 | |
Time: 12:34:13 | 12:34:13 |
Below is my code
Sub textjoin()
Dim csmp As Worksheet
Set csmp = Sheet1
Dim col1 As Range
Set col1 = csmp.Range("t_csmp[Column1]")
'Merge Column 1
Dim cell As Range
nextrow = 2
For Each cell In col1
cell(nextrow, 1).Value = WorksheetFunction.textjoin(" ", True, cell(nextrow, 1), cell(nextrow, 2), cell(nextrow, 3))
nextrow = nextrow + 1
Next cell
End Sub
I got it! Nevermind! Theissue in my code was
cell(nextrow, 1).Value = WorksheetFunction.textjoin(" ", True, cell(nextrow, 1), cell(nextrow, 2), cell(nextrow, 3))
I changed it to
cell = WorksheetFunction.textjoin(" ", True, cell(nextrow, 1), cell(nextrow, 2), cell(nextrow, 3))
Now its working. Duh! lol thank you anyways!