Forum Discussion
Philip Jen
Sep 15, 2017Brass Contributor
How do I delete unused rows in a macro?
I have a sheet into which I record new customer enquiries in consecutive rows. Formula in the same row in subsequent columns pick out keywords and construct an appropriate reply from concatenated...
Smitty Smith
Sep 15, 2017Former Employee
The easiest way is to use a Filter on a column that has your delete criteria, then Go To (F5) > Special > Visible cells only > Delete rows > turn off the filter. All of which is easily recordable.
You can post the resulting code back here, and someone can help you clean it up.
I'd also set your data range up as a table. That way Excel won't care if you have 10 or 100 rows on any given day. A table will automatically extend itself (and formulas), as you enter new data.
You can post the resulting code back here, and someone can help you clean it up.
I'd also set your data range up as a table. That way Excel won't care if you have 10 or 100 rows on any given day. A table will automatically extend itself (and formulas), as you enter new data.
- Philip JenSep 16, 2017Brass Contributor
Smitty Smith wrote:
The easiest way is to use a Filter on a column that has your delete criteria, then Go To (F5) > Special > Visible cells only > Delete rows > turn off the filter. All of which is easily recordable.
... thanks for this. Didn't think of filters so I'm working on it. After selecting "Visible cells only >" I'm not getting "Delete rows" but XThe selection already contains only visible cells"As I say, I'm working on it so any help is invaluable. Thank you for helping.
- Smitty SmithSep 16, 2017Former Employee
If your data is in a table, you can use Alt+H+D+L. If it's in a regular range, you can use Alt+E+D+R. Or the long way, go to Home > Cells > Delete >Delete sheet/table rows.
- Philip JenSep 18, 2017Brass Contributor
Many thanks
I've actually managed to solve the problem in rather a complex way.
I have introduced an IF column of cells filled with IF(data_cell= "",9,1)
so when data is entered in the relevant data_cell the corresponding cell changes from 9 to 1.
Then further IF statements determine IF(cell=1,data,"") so now, all unused cells are blank.
When the Macro adds the cells to the master customer sheet, the SORT ignores the blank cells.
Well, it might not be the best solution, but it works!
Thanks for your help -I'm learning !!