在 Rubberduck 2.0.11.2453 中运行代码检查后,有 4 个 Range 引用被标记为:
成员“范围”隐式引用 ActiveSheet
有问题的范围是指命名范围。是否有必要限定命名范围引用?
Private Sub RunORatio(ByVal TabNum As Integer)
Dim Start As Integer, Cat As Integer, iMth As Integer, CurrentRow As Integer, Report As Integer
Dim wsORatio As Worksheet, wsData As Worksheet, wsMacro As Worksheet
Dim sMap As String, Test As String
With ActiveWorkbook
Set wsMacro = .Worksheets("Macro")
Set wsORatio = .Worksheets("ORatio" & TabNum)
With wsORatio
sMap = "oratio" & TabNum & "map"
For CurrentRow = 1 To Range(sMap).Rows.Count '<---1 here
Test = Range(sMap).Cells(CurrentRow, 1) '<---1 Here
Set wsData = ActiveWorkbook.Worksheets(Test)
Start = Range(Range(sMap).Cells(CurrentRow, 2)).Row '<---2 Here
Report = wsMacro.Range(sMap).Cells(CurrentRow, 3)
For Cat = 0 To 12
For iMth = 1 To 12
wsORatio.Cells(Report + Cat, 7 + iMth) = wsData.Cells(Start + Cat, 37 + iMth)
Next iMth
Next Cat
Next CurrentRow
End With
End With
End Sub