Results 1 to 5 of 5

Custom written TEXTJOIN - How to alternate delimters

Threaded View

  1. #1
    Registered User
    Join Date
    08-12-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    5

    Post Custom written TEXTJOIN - How to alternate delimters

    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
    Last edited by GreedyG; 08-12-2019 at 06:18 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] TEXTJOIN and keep formatting
    By ihb95 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-09-2019, 03:16 AM
  2. Textjoin?
    By johandenver in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 10-01-2017, 03:18 PM
  3. TEXTJOIN function
    By Tony Valko in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-13-2016, 06:48 PM
  4. Custom VB Written Message for Protected Cells
    By robertguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2013, 04:09 PM
  5. Excel returns @name? error when using a custom written function in
    By Al Maher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2006, 08:35 AM
  6. Alternate Color Lines when using Custom Views
    By GLT in forum Excel General
    Replies: 7
    Last Post: 11-13-2005, 10:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1