0

I have a report that has to filter out Terminated employees, I have a macro that filters by column S, selects all terminated EE's, then deletes those rows. However, it's not guaranteed that the first terminated EE will always be on the same row. For instance, it could be row 22 this week and then row 16 next week. The code I have now for that part of the macro is

Application.Goto Reference:="R1C1"
ActiveCell.Offset(1).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete

It is supposed to go to A1 and then drop down to the next shown row (first terminated EE) and then select and delete those rows. As I mentioned earlier, that first shown row can vary from week to week. What code should I use to accurately delete the first shown row each week?

  • See [How to avoid using `Select`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). It's got the answers to basically your entire question. – BigBen Aug 21 '20 at 18:48
  • I'm trying to read through that page but I don't understand much of it. Don't have any coding experience/maco training. I just record myself doing tasks and then edit pieces that are bad with helpful info from the internet. What part should I be focusing on? – LittleAuditorium Aug 21 '20 at 18:56
  • 2
    Actually after a re-read, maybe you actually want to do [this](https://stackoverflow.com/questions/49774855/vba-delete-visible-rows-after-filter-applied). – BigBen Aug 21 '20 at 19:09
  • Yeah that's beautiful. Looks to be exactly what I'm looking for. – LittleAuditorium Aug 21 '20 at 19:18

0 Answers0