I am running a report of employees who charge time to different codes. The report gives me the following columns:
Emp# / Emp Name / Rate / TermDate
If the employee has left, then there is a value in the TermDate column.
Because the value in the cell could be any date, I want to write a macro that will search the list and delete any row in which the value in the fourth column is NOT blank.
I've found several examples of how to delete a row based on blank cells, or based on certain values, but none on a non-blank value.
Each report will have a different number of rows as well so I need help selecting the range and deleting rows in the range based on the value of the final column.
Fastest way. Use
.Autofilter
. No need to loop...My solution would be:
This assumes that the column to check is column D
If I understand correctly, then you want something like this?
It is assumed that TermDate is in column D.
Consider using a filter on the data instead. You didn't mention what version of Excel, but in 2010 go to the data tab, select the termdate column, then click on "filter".
Notice a little dropdown arrow appears in the first cell of the column. Click on that, then deselect all but the "blanks" selection. Wha-la.
That way the data is still there for history if you need it.
Oh and after applying the filter, a little funnel icon will remain in the first cell of the column to show it's a filtered column.