PDA

View Full Version : VBA Excel - Filter selection “wrong” row



cjvdg
01-31-2021, 10:51 PM
I'm new to this VBA thing. I just want to ask if why does the selection of my header is in the wrong row? I mean, it should be in Row 8, right? But why does it shows in Row 2?

27831

The header should be in Row 8 because I have other stuff in Row 1 to Row 6.



For Each ws In Sheets(Array("G1-Q1", "G1-Q2"))

With ws.Cells(8, 3).CurrentRegion
.AutoFilter 2, StudID
.Offset(1).EntireRow.Delete
'ws.AutoFilterMode = False
End With

Next ws


The ws.Cells(8, 3) means that it is in Row 8 and Column C, right?

jolivanes
02-01-2021, 12:03 AM
Re: "I have other stuff in Row 1 to Row 6." and "With ws.Cells(8, 3).CurrentRegion"
If it does not do what you think it should do, you could check with

Sub Check_How_Current_Region_Works()
ActiveSheet.Cells(8, 3).CurrentRegion.Select
End Sub
Doe you get the result you expect?