0

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?

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, " ", "")
Next i
End Sub
BigBen
  • 38,994
  • 6
  • 24
  • 37
Enna
  • 1

0 Answers0