Sometimes we hide certain rows or columns because we don’t want the data to print, or just to get it out of the way. Other times though we simply don’t want to share the data in a hidden row or column. Assuming that the data in visible cells isn’t dependent on the data in hidden cells (i.e. if a formula references a hidden cell), we can use the macro below to automatically delete any hidden rows and columns in the active worksheet.
If you only want the hidden rows to be deleted, remove the three lines starting with For Ip = 256 through Next. To only delete the hidden columns, remove the next three lines starting with For lp = 65536 through Next.
Copy all of the code below. Paste it into your workbook’s Visual Basic editor, either under a Microsoft Excel Object or Module.
Need help? Use our nifty guide to help figure out how to install and use your macros.