title: How to mass update worksheet names using Excel VBA code -for multiple excel files
body: <p>I have multiple excel files in one folder. Each Excel file has trailing and leading spaces worksheet names. I would like to use below VBA code for multiple excel files instead of opening each excel file and running the code--is there an easy way to run this code for multiple excel files automatically?</p>
  <pre><code>Sub remove_leading_spaces()
  Dim i As Integer
  Dim WkSht_Count As Integer
  WkSht_Count = ThisWorkbook.Sheets.Count
  For i = 1 To WkSht_Count
  Sheets(i).Select
  ActiveSheet.Name = Replace(ActiveSheet.Name, &quot; &quot;, &quot;&quot;)
  Next i
  End Sub
  </code></pre>