If you want to efficiently concatenate many strings, you can define a stringbuilder class.
Running the code below to create a string of numbers up to a million takes only a fraction of a second (0.3 s). Creating an array and using Join is just around the corner (0.25 s), calling the Join function takes about 10% of that time.
If the lines are already in the array, then it makes sense to use Join , but with a small number of lines the difference is unlikely to be noticeable in any case.
Sub JoinStringTest() Dim i As Long, t As Double Dim sb As New StringBuilder Dim sbRet As String Dim joinRet As String t = Timer For i = 1 To 1000000 sb.Append CStr(i) Next sbRet = sb.Text Debug.Print "SB", Timer - t t = Timer Dim a(1000000) As String For i = 1 To 1000000 a(i) = CStr(i) Next i joinRet = Join(a, "") Debug.Print "Join", Timer - t Debug.Print sbRet = joinRet End Sub
source share