编译此代码时,我总是遇到此错误:
Private Sub CommandButton1_Click()
Dim rng As String
Dim x As String
Dim i As Integer
Dim ws As Worksheet
Set ws = ActiveWorkbook.Worksheets("Budget")
x = range("A20").Value
For i = 2 To 20
If Cells(i, 1) = x Then
rng = ws.range(ws.Cells(i, 17)).Value
End If
Next I
MsgBox rng
Worksheets("Shortage").Activate
Worksheets("Shortage").range(rng).Activate
End Sub
非常感谢。