提问人:jacopo salmistrari 提问时间:6/18/2022 最后编辑:Communityjacopo salmistrari 更新时间:3/16/2023 访问量:183
遍历工作簿中的所有工作表
Loop through all sheets in workbook
问:
我有一个包含 100 张纸的 Excel 文件,所有文件的布局都相同。
我需要遍历所有工作表以应用格式。
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Balance Sheet"
Range("Q1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Cash Flow"
Next ws
End Sub
答:
1赞
Bryan
6/19/2022
#1
将其替换为:
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Range("A1").Value = "Balance Sheet"
ws.Range("Q1").Value = "Cash Flow"
Application.CutCopyMode = False
Next ws
评论
ws
ws.range("A1").FormulaR1C1 = "Balance Sheet"
Application.CutCopyMode = False
Select
ws
ws.Range("A1").Select
Select
ActiveCell