![]() |
|
#1
|
||||
|
||||
![]() You can keep passing variables across functions but I think it is easier to declare a variable so it can be used by all the sub/functions in the module. This then persists and can be added to or read by any of the subs or functions. This illustrates the concept. Code:
Option Explicit Private arr1() As String, sArr As String Sub TheLoop() Dim i As Integer sArr = "" 'this empties the string in case the macro was run earlier For i = 1 To 10 TheTest i Next i ThePayout: MsgBox sArr arr1 = Split(sArr, "|") End Sub Sub TheTest(i As Integer) If i Mod 2 = 0 Then TheLogger i End If End Sub Sub TheLogger(i As Integer) If sArr = "" Then sArr = "Item " & i Else sArr = sArr & "|" & "Item " & i End If End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#2
|
|||
|
|||
![]()
Hi Andrew -- A belated thank you for your reply and sample code!
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Looping through a folder of PDF files and saving them as docx | ballpoint | Word VBA | 5 | 11-22-2018 05:18 AM |
![]() |
Peterson | Word VBA | 2 | 04-19-2018 08:45 AM |
![]() |
gbaker | Outlook | 9 | 04-22-2016 11:02 PM |
VBA Word - Search Within Files Containing A String - Copy Files to New Folder | jc491 | Word VBA | 0 | 01-09-2016 12:00 PM |
![]() |
obasanla | Word | 1 | 09-28-2012 04:42 PM |