user4143092
user4143092

Reputation: 11

How to run a vba macro for multiple excel files

I am a naive user of VBA and I am looking for a VBA macro which would do the following task

  1. Delete 3 tabs from the file and delete the first 6 rows from remanining tabs.
  2. Perform this for all the excel files (2013) and save as xlsx in the same or different file folder.

I tried the code available on this link Run same excel macro on multiple excel files

At the line Filename=Dir(Pathname & "*.xlsx") , I am getting an error which says run time error "52" Bad file name or number.

I have changed this:

Pathname = "\C:\Users\Desktop\test\try\"\

Is this correct?

Upvotes: 1

Views: 494

Answers (1)

nwhaught
nwhaught

Reputation: 1592

Not sure if it's your only problem, but

\C:\Users\Desktop\test\try\

should be

C:\Users\Desktop\test\try\ (without the first backslash)

*I realize this should be a comment--I'm under 50 rep, however.

Upvotes: 1

Related Questions