Advertisement
anatak

Excel VBA

Aug 2nd, 2019
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Excel Join String
  2. Function STR_JOIN(arg1 As range, Optional seperator As String = ",") As String
  3.     Dim statement As String
  4.     Dim last_index As Integer
  5.     Dim index As Integer
  6.    
  7.     ' Find Total Records
  8.    last_index = arg1.Count - 1
  9.    
  10.     ' Reset Index to Zero
  11.    index = 0
  12.    
  13.     For Each elem In arg1
  14.    
  15.         If index = last_index Then
  16.             statement = statement + elem.Value
  17.         Else
  18.             statement = statement + elem.Value + Trim(seperator)
  19.         End If
  20.        
  21.         index = index + 1
  22.     Next elem
  23.    
  24.     STR_JOIN = statement
  25. End Function
  26.  
  27. ' Remove Space From String
  28. Function SPACE_REMOVE(Txt As String) As String
  29.     With CreateObject("VBScript.RegExp")
  30.     .Global = True
  31.     .Pattern = "\D"
  32.     SPACE_REMOVE = .Replace(Txt, "")
  33.     End With
  34. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement