Public sub ProcessSheets()
Dim ws As Excel.Worksheet
Dim iIndex As Integer
'Loop through all the worksheets in the workbook.
For iIndex = 1 To ActiveWorkbook.Worksheets.count
'Activate the current sheet, if you need to.
Set ws = Worksheets(iIndex)
ws.Activate
'Check the name of the worksheet.
If Left(ws.Name, 2) = "HD" or Left(ws.Name, 2) = "ER" Then
'Call the function that changes the worksheet here.
'Maybe feed it the worksheet name.
UpdateWorksheet ws.Name
End if
Next iIndex
End Sub
2 回答
基于MrExcel.com forum的建议:
我知道这不是你问题的答案,但我只是提供一些信息 . 我建议您没有用户在每个工作表中创建一个宏 . 您可以从模块访问任何工作表上的任何内容 . 我不确定你的整个过程是什么,但你可以更多地考虑寻找你想要改变的床单 .