title: Concatenating in Excel For Loop to make batch file of commands
body: <p>Consider this scenario: I have a client who has two network shares on a server. Each share contains an identical list of folders representing each project (one is for current data, and the other share for archived data). Each project folder contains a matching set of folders and subfolders which need individual permissions assigned. Of course projects are added and removed from time to time. </p>
  
  <p>I'd like to maintain a list of the projects in Excel along with a list of the permissions that need to be set for each project folder as well as all their subfolders. My idea is to lay out the commands in Excel one per row with each row representing a subfolder. Then use for loops to duplicate these commands adding on the shared folder and project folder to the directory path. The output would be a batch file that I could run any time permissions needed to be changed or updated. </p>
  
  <p>EDIT:
  I've never used VBA in Excel, and after searching I can't seem to find how to use variables in a for loop to change which cells in the sheet are referenced. It's been a while since I wrote any program, but when I was programming in C I remember being able to use the variables from the for loops to reference cells in a list/table. As the for loop went through iterations the variables would count up changing which cell in the list they were referencing. To put this in Excel terms I want the variable from each for loop to be the row number, and I will statically assign the column letter since that's not changing with each iteration.</p>
  
  <p>Each time the for loop runs I want it to concatenate a series of cells into a text string that is output to a new line of a text file. The concatenation will tie together some cells that remain the same during each loop, and other cells that are changing as the variables are incremented. For example I want to concatenate cells A1, B1, Ci, Dj, E1, Fk where i, j, and k represent the numeric value of the integer used to count the iterations of each for loop. </p>
  
  <p>Can you tell me what the proper syntax is to accomplish concatenation with variable cell assignments? Here's an excerpt from my code.</p>
  
  <pre><code>For i = 2 To numberOfSharedFolders
  
          'Loops for every subfolder (project folder) in the shared folder that needs permissions set
          For j = 2 To numberOfSubfolders1
  
              'Loops for every entry of permissions on final folders
              For k = 2 To numberOfSubfolders2
  
                  concatenatedDataString = ActiveSheet.Range("A1") &amp; ActiveSheet.Range("B1") &amp; ActiveSheet.Range("C"i) &amp; ActiveSheet.Range("D"j)
                  Write #1, concatenatedDataString
  
              Next k
          Next j
      Next i
  </code></pre>