title: How can I open multiple worksheets, add the sum of the columns in each of them and save it?
body: <p>im trying to program a macro in excel for my thesis. I got multiple .xlsx Files in a folder, each containing a table of 9 columns (A-I) and a varying number of rows. I would like to automatically open each file, add the sum of the columns on the bottom of each column and afterwards save the file.</p>
  
  <p>I have found a code here in stack overflow to choose a folder with .csv files which are automatically opened and saved as .xlsx files in the same folder. I tried to modify the code for my purpose. 
  The only thing I achieved was to change the code so far as to open the .xlsx files of my folder. 
  From that point on I have no idea how to go on since I don't have any experience with VBA. 
  GetFolder() is a definded function which allows me to browse for a folder and get out it's path.</p>
  
  <p>Private Sub CommandButton1_Click()</p>
  
  <pre><code>Dim myFolder As String
  Dim getBook As String
  Dim myCSVFile As String
  Dim LastRow As Long
  
  
  Application.DisplayAlerts = False
  myFolder = GetFolder()
  myXLSXFile = Dir(myFolder &amp; "\*.xlsx")
  
  Do While myXLSXFile &lt;&gt; ""
      Workbooks.Open Filename:=myFolder &amp; "\" &amp; myXLSXFile
      getBook = ActiveSheet.Name
      ActiveSheet.Name = "Sheet1"
  </code></pre>
  
  I think at this point the code for adding the sum at the end of the column should be but im not sure
  
  <pre><code>    ActiveWorkbook.SaveAs Filename:=myFolder &amp; Chr(92) &amp; getBook, FileFormat:=51
      ActiveWorkbook.Close False
      myXLSXFile = Dir
  Loop
  </code></pre>
  
  <p>End Sub</p>