错误excel vba“方法范围对象_global失败”

时间:2012-12-17 01:29:24

标签: excel vba excel-vba excel-2007

这是我的代码

Sub rangking()
Dim mulai As Integer
Dim akhir As Integer
Dim i As Integer
Application.CutCopyMode = False
mulai = 0
akhir = 60
For i = akhir To mulai Step -1
If Range("data!AC" & i).Value > 90 Then
Range("data!AO" & i).Value = "mumtaz"
ElseIf Range("data!AC" & i).Value > 80 Then Range("data!AO" & i).Value = "jayid jiddan"
ElseIf Range("data!AC" & i).Value > 70 Then Range("data!AO" & i).Value = "jayid"
ElseIf Range("data!AC" & i).Value > 60 Then Range("data!AO" & i).Value = "hasan"
ElseIf Range("data!AC" & i).Value > 50 Then Range("data!AO" & i).Value = "kaaf"
ElseIf Range("data!AC" & i).Value > 45 Then Range("data!AO" & i).Value = "makbul"
Else: Range("data!AO" & i).Value = "rosib"
End If

Next i

End Sub

我有错误“方法'范围'对象'_global'失败” 在行

If Range("data!AC" & i).Value > 90 Then

请帮帮我

1 个答案:

答案 0 :(得分:2)

Range("data!AC" & i)

不是您需要单独定义工作表的范围 例如:

Sheets("data").Range("AC" & i)