I created a macro by recording it, where I want to set an autofilter on a table that starts at row 11 and then select multiple entries.
This is the relevant part of that code and it includes cell T4806 because that is CURRENTLY the last row of data.
But the file is updated each week so next week there may be more or less data. It will always be row T though.
I searched elsewhere and came up with this next line to identify the last row of data and I know it does work. I put that line before the code above.
LR = Worksheets("MyDataSheet").Cells(Rows.Count, 2).End(xlUp).Row
But how should I change the code to incorporate LR? I tried various combinations like "$B$11:$T$"&LR&" but none work.
This is the relevant part of that code and it includes cell T4806 because that is CURRENTLY the last row of data.
Code:
ActiveSheet.Range("$B$11:$T$4806").AutoFilter Field:=7, Criteria1:=Array( _
"Breast Surgery", "Colorectal Surgery", "ENT", "General Surgery", "Oral Surgery", _
"Paediatric Surgery", "Plastic Surgery", "Trauma And Orthopaedics", "Urology"), _
Operator:=xlFilterValues
But the file is updated each week so next week there may be more or less data. It will always be row T though.
I searched elsewhere and came up with this next line to identify the last row of data and I know it does work. I put that line before the code above.
LR = Worksheets("MyDataSheet").Cells(Rows.Count, 2).End(xlUp).Row
But how should I change the code to incorporate LR? I tried various combinations like "$B$11:$T$"&LR&" but none work.