Hello there,
I'm pretty new to VBA and have some VBA code, which is a stand in for the TEXTJOIN function in Office 365. Since I dont have access to 365, only standard MS-Office 2016 I was looking for a replacement for TEXTJOIN.
I found something online using VBA. Since my knowledge in VBA is basic and limited (I know what the code does, I alternated a few lines to make it fit) I was happy that it worked.
But now I want to add something. I have a worksheet with around 32000 rows, and I cant edit every row by hand.
Thing is: I have 1 delimiter. But I need two. Basically, it should alternate between both delimiters.
Example: TEXT1 - TEXT 2 _ TEXT3 - TEXT4 _ TEXT5 .......
As of right now, it only uses TEXT1 - TEXT2 - TEXT3......
That is my try on alternating delimters, but it doesnt work:
Option Explicit
Public Function TEXTVERKETTEN(Delimiter As String, AltDelim As String, Ignore_Empty As Boolean, ParamArray Text1() As Variant) As String
Dim RangeArea As Variant
Dim Cell As Range
Dim i As Integer
i = 0
'Loop Through Each Cell in Given Input
For Each RangeArea In Text1
i = i + 1
If i Mod 2 = 0 Then
If TypeName(RangeArea) = "Range" Then
For Each Cell In RangeArea
If Len(Cell.Value) <> 0 Or Ignore_Empty = False Then
TEXTVERKETTEN = TEXTVERKETTEN & Delimiter & Cell.Value
End If
Next Cell
Else
If Len(RangeArea) <> 0 Or Ignore_Empty = False Then
TEXTVERKETTEN = TEXTVERKETTEN & Delimiter & RangeArea
End If
End If
Else
If TypeName(RangeArea) = "Range" Then
For Each Cell In RangeArea
If Len(Cell.Value) <> 0 Or Ignore_Empty = False Then
TEXTVERKETTEN = TEXTVERKETTEN & AltDelim & Cell.Value
End If
Next Cell
Else
If Len(RangeArea) <> 0 Or Ignore_Empty = False Then
TEXTVERKETTEN = TEXTVERKETTEN & AltDelim & RangeArea
End If
End If
End If
Next RangeArea
TEXTVERKETTEN = Mid(TEXTVERKETTEN, Len(Delimiter) + 1)
End Function
"TEXTVERKETTEN" is the german equivalent to TEXTJOIN.
If you need anything to help me, please let me know.
Thanks in advance
Greedy
Bookmarks