我有一个问题,我想做一个简单的代码来检查值,然后查找下一个No No empty cell。我尝试这样做,但是有问题:
Sub test()
Dim ark1 As Worksheet, ark2 As Worksheet
Dim i As Long, j As Long, lastRow As Long, nextRow As Long, actCell As Long, actCell2 As Long
Set ark1 = Worksheets("Arkusz1")
Set ark1 = Worksheets("Arkusz2")
For i = 1 To 20
If ark1.Cells(i, "A") = ark1.Cells(1, "B") Then
ark1.Cells(i, 1).Select
actCell = ActiveCell.Row
MsgBox actCell
End If
Next i
For i = actCell To 20
ark1.Cells(i, "A").Select
If IsEmpty(ActiveCell) Then
Next i
Else
ark1.Cells(i, "A") = 1
End If
Next i
End Sub
感谢JvdV,我找到了解决方案,也许对某人有用:
Sub test()
Dim ark1 As Worksheet
Dim i As Long, j As Long, lastRow As Long, nextRow As Long, actCell As Long, actCell2 As Long
Set ark1 = Worksheets("Arkusz1")
For i = 1 To 20
If ark1.Cells(i, "A") = ark1.Cells(1, "B") Then
ark1.Cells(i, 1).Select
actCell = ActiveCell.Row
MsgBox actCell
End If
Next i
' Next no empty cell
For i = actCell + 1 To 20
If IsEmpty(ark1.Cells(i, "A")) Then
Else
ark1.Cells(i, 1).Select
actCell2 = ActiveCell.Row
MsgBox "The active cell is not empty " & actCell2
Exit For
End If
Next i
End Sub