Can you batch edit (change) 100 identical spreadsheets?

I have 100 or so identical spreadsheets in a directory. Identical layout but different entries in each spreadsheet. I need to format a number of cells to "shrink to fit." Is there a way to batch edit that many spreadsheets?

In the alternative, I created a macro to do a single spreadsheet. How do I save it in the directory so that anyone bringing up a spreadsheet in that directory can run that macro?
Bill GoldenExecutive Managing MemberAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Panagiotis ToumpaniarisSystem EngineerCommented:
You can use VBA to do that.

This code will set shrink to fit to true for the first column.
Sub test()
Range("A:A").ShrinkToFit = True
End Sub

Open in new window

To make this work for many workbooks follow the guides here :

hope it helps
Just use the vbs to do it.

The VBS script like below codes(not test yet):
  Dim xpp, book, fso, files
  Set xpp = CreateObject("Excel.Application")
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set files = fso.GetFolder("Your Folder which store 100+ Excel Files").files
  For Each f In files
    book = Application.Workbooks.Open(f)
    ' change the sheet name and range as you want
    book.Sheets("Sheet1").Range("A:A").ShrinkToFit = True
    Set book = Nothing
  Set files = Nothing
  Set fso = Nothing

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Panagiotis ToumpaniarisSystem EngineerCommented:
Both ways work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.