Ik heb een tabel met drie kolommen, Ik wil kolom C stap voor stap filteren met met de waarden 1 tot en met .... (tig).
Mijn code veroorzaakt een foutmelding 424: object vereist!
Wat doe ik fout?
Private Sub cmdBijwerken()
'Koppelt het nummer vna de foto aan het inventarisnummer
'Step 1: Declare your Variables
Dim cl, rng As Range
Dim n, lastrow As Integer
'Specify ranges
lastrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).row
Set rng = ActiveSheet.Range(Cells(1, 1), Cells(lastrow, 3)) 'kolom C
MsgBox "Laatste rij =" & lastrow
For n = 1 To lastrow
rng.AutoFilter Field:=1, Criteria1:=n.Value, Operator:=xlAnd
MsgBox n
For Each cl In rng
If cl.EntireRow.Hidden = False Then '' Use Hidden property to check if filtered or not
If c1 <> "" Then MsgBox cl.Offset(0, -1)
End If
Next
Next 'n
End Sub
Mijn code veroorzaakt een foutmelding 424: object vereist!
Wat doe ik fout?
Private Sub cmdBijwerken()
'Koppelt het nummer vna de foto aan het inventarisnummer
'Step 1: Declare your Variables
Dim cl, rng As Range
Dim n, lastrow As Integer
'Specify ranges
lastrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).row
Set rng = ActiveSheet.Range(Cells(1, 1), Cells(lastrow, 3)) 'kolom C
MsgBox "Laatste rij =" & lastrow
For n = 1 To lastrow
rng.AutoFilter Field:=1, Criteria1:=n.Value, Operator:=xlAnd
MsgBox n
For Each cl In rng
If cl.EntireRow.Hidden = False Then '' Use Hidden property to check if filtered or not
If c1 <> "" Then MsgBox cl.Offset(0, -1)
End If
Next
Next 'n
End Sub