我有一个宏,它将首先刷新访问数据库的所有数据连接 - 然后它将遍历每个工作表以替换一些文本并格式化每个工作表;它应该退出宏 - 但是在它结束时,由于某种原因它再次刷新工作簿,即使该代码在循环之外!
Sub RefreshBonus()
'
' RefreshBonus Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim c As Range
' Refresh all data
ThisWorkbook.RefreshAll
' Remove the text in front of the text to make formulas active
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Activate
Set c = ActiveSheet.UsedRange
c.Replace What:="_CT", replacement:="", Lookat:=xlPart, MatchCase:=True
Next
'Format the sheet
Sheet2.Activate
Columns("G:AA").Select
Selection.ColumnWidth = 10
Rows("1:1").Select
Selection.RowHeight = 48
Sheet3.Activate
Columns("A:T").Select
Selection.ColumnWidth = 10
Sheet3.Rows("1:1").Select
Selection.RowHeight = 48
Sheet6.Activate
Columns("A:O").Select
Selection.ColumnWidth = 10
Rows("1:1").Select
Selection.RowHeight = 48
End Sub
如何防止它再次刷新工作簿,让我的字符串替换和格式保持不变?