简体   繁体   English

如何为多个Excel文件运行VBA宏

[英]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 我是VBA的天真的用户,并且我正在寻找可以执行以下任务的VBA宏

  1. Delete 3 tabs from the file and delete the first 6 rows from remanining tabs. 从文件中删除3个标签,然后从重新剩余的标签中删除前6行。
  2. Perform this for all the excel files (2013) and save as xlsx in the same or different file folder. 对所有Excel文件(2013)执行此操作,然后另存为xlsx在相同或不同的文件夹中。

I tried the code available on this link Run same excel macro on multiple excel files 我尝试了此链接上可用的代码在多个Excel文件上运行相同的Excel宏

At the line Filename=Dir(Pathname & "*.xlsx") , I am getting an error which says run time error "52" Bad file name or number . Filename=Dir(Pathname & "*.xlsx") ,我收到一条错误,指出run time error "52" Bad file name or number

I have changed this: 我改变了这个:

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

Is this correct? 这个对吗?

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) C:\\Users\\Desktop\\test\\try\\ (不带第一个反斜杠)

*I realize this should be a comment--I'm under 50 rep, however. *我意识到这应该是一条评论-但是,我的代表不到50岁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM