以下是執行的程式,但執行出來的結果有誤,如附件,請各位先進協助邦小弟解惑
Private Sub CommandButton1_Click()
Dim Ay(4, 2), D As Range
Ay(0, 0) = 1: Ay(0, 1) = "3500內": Ay(1, 0) = 3499: Ay(1, 1) = "4000內": Ay(2, 0) = 3999: Ay(2, 1) = "6000內": Ay(3, 0) = 6001: Ay(3, 1) = "6000上"
With Sheet1
Set D = .Range(.[B10], .[B65536].End(xlUp))
For Each N In D
If N <> "" Then
m = N
P = Application.VLookup(m, Ay, 2)
If Not IsError(P) Then D.Offset(, 1) = P
End If
Next
End With
End Sub作者: GBKEE 時間: 2012-1-13 17:03
回復 1#lone_tiger0303
If Not IsError(P) Then D.Offset(, 1) = P 變數要弄清楚
For Each n In D
If n <> "" Then
m = n
P = Application.VLookup(m, Ay, 2)
If Not IsError(P) Then n.Offset(, 1) = P ''' 不是 D.Offset(, 1) = P