Nick
asked on
VBA way to remove unused cells and raws from Excel
Experts, I am looking for VBA solution to remove all unused cells and raws from excell the only sheet.
code.xlsm
code.xlsm
Why do you need VBA? Just hide the unused rows and columns, that's it.
ASKER
ok, how can I do it with VBA?
ASKER
VBA because I have another bigger project in mind, and by doing this one I learn from your solutions.
Based on your file, simply try this...
Place the following code on a Standard Module like Module1.
Place the following code on a Standard Module like Module1.
Sub HideRowsAndColumns()
Columns("C:XFD").Hidden = True
Rows("13:1048576").Hidden = True
End Sub
ASKER
Sorry for another silly question: how do I call this sub on a sheet loading or activation?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want to remove unused rows and columns or do you want to just hide them? Also as far as I can see, the workbook you posted has no data. Do you have a sample workbook that does have data?
ASKER
I would like to remove unused cells and columns so excel would look more like an application. Hiding does not give it the right look.
ASKER
Subodh, not sure if I touched something but it shows me an error that it can not hide cells. I saw it working at least once.
code.xlsm
code.xlsm
I'm sure that Neeraj or I can provide you with a solution, but speaking for myself, I'd like you to close your previous questions before I supply a solution.