Excel宏:初学者 - 从一个工作簿粘贴到另一个工作簿的格式 [英] Excel Macro: Beginner - Pasting Formats from one Workbook to Another
问题描述
我想将每个工作表格式(每个工作表上的格式不同)复制到此工作簿(K:\Common\HSRE\\ \\ Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Results_2012 - Template.xlsx)。此工作簿中的工作表名称与第一个工作簿中的名称相同。
根据我在网上看到的内容,我以为我可以做一些事情(至少在第一个工作表)
Sub FormatMAC()
工作簿(K:\Common\HSRE\\ \\ Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Results_2012 - Template-Master.xlsx)。Worksheets(Provider Level)。Range(A1:CZ600 ).Copy
工作簿(K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Copy of结果_2012 - Template1.xlsx)工作表(提供程序级别)范围(A1:CZ600)。PasteSpecial(xlPasteFormats)
End Sub
似乎程序正在挂起第一行。我不断收到这个错误
运行时错误`9':下标超出范围
任何想法?
如果工作簿打开,则不需要提供整个路径
尝试这个
工作簿(Results_2012 - Template - Master)工作表(提供者级别)范围A1:CZ600)。复制
与另一个相同。
I dont know Excel Macros so I'm sure this is a ridiculous question. I have an excel workbook here with 7 worksheets (K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Results_2012 - Template – Master.xlsx)
I want to copy the formatting from each of those worksheets (the formats are different on each worksheet) to this workbook (K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Results_2012 – Template.xlsx). The worksheet names in this workbook are identical to the names in the first workbook.
Based on what I saw online I thought I could do something like (at least for the first worksheet)
Sub FormatMAC()
Workbooks("K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Results_2012 - Template - Master.xlsx").Worksheets("Provider Level").Range("A1:CZ600").Copy
Workbooks("K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for MACs\Results\Copy of Results_2012 - Template1.xlsx").Worksheets("Provider Level").Range("A1:CZ600").PasteSpecial (xlPasteFormats)
End Sub
It seems like the program is getting hung up on the first line. I keep getting this error
Run-time error `9’: Subscript out of Range
Any ideas?
If the workbook is open then you don't need to supply the entire path
Try this
Workbooks("Results_2012 - Template - Master").Worksheets("Provider Level").Range("A1:CZ600").Copy
Same with the other.
这篇关于Excel宏:初学者 - 从一个工作簿粘贴到另一个工作簿的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!