我刚收到一个包含多个宏的旧excel文件。当我尝试使用它时,我总是收到错误消息"下标超出范围"。我认为错误在于以下代码,但由于我对VBA的了解有限,我无法找到它。你能检查下面的代码吗?非常感谢!
Sub MD1()
Dim sh As String
Dim ce As String
Dim n As Integer
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As Double
Dim e As Double
Dim r As Integer
n = Sheets("setup").Range("c11")
sh = Sheets("setup").Range("c14")
ce = Sheets("setup").Range("c15")
For r = 3 To n + 3
Sheets(sh).Range(ce) = Sheets("MD1").Range("A" & r)
a = Sheets("setup").Range("F17")
b = Sheets("setup").Range("G17")
c = Sheets("setup").Range("H17")
d = Sheets("setup").Range("I17")
e = Sheets("setup").Range("J17")
Sheets("MD1").Range("B" & r) = a
Sheets("MD1").Range("C" & r) = b
Sheets("MD1").Range("D" & r) = c
Sheets("MD1").Range("E" & r) = d
Sheets("MD1").Range("F" & r) = e
Next