It should work as desired for the active sheet. Try it. I need to correct lr to lc as below. Sub cleanrowsandcolumnsSAS() lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _ , , , xlByRows, xlPrevious).Row + 1 lc = Cells.Find("*", Cells(Rows.Count, Columns.Count) _ , , , xlByColumns, xlPrevious).Column + 1 Application.EnableEvents = False Rows(lr).Resize(Rows.Count - lr).Delete Columns(lc).Resize(, Columns.Count - lc).Delete Application.EnableEvents = True ActiveWorkbook.Save End Sub
From: Amit Desai (MERU) Sent: Tuesday, August 23, 2011 10:36 PM To: excel-macros@googlegroups.com Subject: RE: $$Excel-Macros$$ how to delete multiple row & columns Thanks a lot for the solution. Can you tell me how shall I use this? I mean How shall I paste this code so that macro works.. & hope it will delete only blank cells on the right & bottom !!!-:) -------------------------------------------------------------------------------- From: excel-macros@googlegroups.com [excel-macros@googlegroups.com] On Behalf Of STDEV(i) [setiyowati.d...@gmail.com] Sent: Wednesday, August 24, 2011 6:29 AM To: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ how to delete multiple row & columns A little correction Sub cleanrowsandcolumnsSAS() lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _ , , , xlByRows, xlPrevious).Row + 1 lc = Cells.Find("*", Cells(Rows.Count, Columns.Count) _ , , , xlByColumns, xlPrevious).Column + 1 Application.EnableEvents = False Rows(lr).Resize(Rows.Count - lr).Delete Columns(lc).Resize(, Columns.Count - lr).Delete Application.EnableEvents = True ActiveWorkbook.Save End Sub '--thank you siti Vi On Tue, Aug 23, 2011 at 7:37 PM, dguillett1 <dguille...@gmail.com> wrote: If I understand your request, you may like this. It also saves the file Sub cleanrowsandcolumnsSAS() lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _ , , , xlByRows, xlPrevious).Row lc = Cells.Find("*", Cells(Rows.Count, Columns.Count) _ , , , xlByColumns, xlPrevious).Column Application.EnableEvents = False Rows(lr).Resize(Rows.Count - lr).Delete Columns(lc).Resize(, Columns.Count - lr).Delete Application.EnableEvents = True ActiveWorkbook.Save End Sub From: Amit Desai (MERU) Sent: Tuesday, August 23, 2011 1:32 AM To: excel-macros@googlegroups.com Subject: $$Excel-Macros$$ how to delete multiple row & coulmns Dear All, Please let me know how to delete multiple rows(say from my last data based row # 678 to last row) & multiple columns (say from AA to last column). This is taking a lot of file size⦠Best Regards, Amit Desai -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -------------------------------------------------------------------------------- Disclaimer: This message and its attachments contain confidential information and may also contain legally privileged information. This message is intended solely for the named addressee. If you are not the addressee indicated in this message (or authorized to receive for addressee), you may not copy or deliver any part of this message or its attachments to anyone or use any part of this message or its attachments. Rather, you should permanently delete this message and its attachments (and all copies) from your system and kindly notify the sender by reply e-mail. Any content of this message and its attachments that does not relate to the official business of Meru Cab Company Pvt. Ltd. must be taken not to have been sent or endorsed by any of them. Email communications are not private and no warranty is made that e-mail communications are timely, secure or free from computer virus or other defect. -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel