我在sheet1中有3張(sheet1,sheet2,sheet3)擁有所有用戶ID,sheet2具有登錄用戶ID,而sheet3是空的。重點是...我需要不將用戶ID登錄到sheet3,但我的代碼失敗。如果這是一個愚蠢的問題,因爲我是新手用VBA如何在excel中使用VBA插入數據
這裏我的代碼:
Sub NotLog()
Dim c1 As Range
Dim c2 As Range
Dim c3 As Range
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim sh3 As Worksheet
Set sh1 = ThisWorkbook.Sheets("ALl USer")
Set sh2 = ThisWorkbook.Sheets("8_Logon_SOE_by_group")
Set sh3 = ThisWorkbook.Sheets("Not Logon")
For Each c1 In sh1.Range("A2:A99")
For Each c2 In sh2.Range("A3:A99")
If c1 <> c2 Then
For Each c3 In sh3.Range("A2:A99")
If IsEmpty(Range("c3").Value) = True Then
c3 = c1
ElseIf IsEmpty(Range("c3").Value) = False Then
Exit For
End If
Next c3
Else
Exit For
End If
Next c2
Next c1
End Sub
http://i.stack.imgur.com/2kDEH.png ......這是我的輸出。 http://i.stack.imgur.com/IWSZM.png ......應該是這樣的。