![]() |
How can this code be made more efficient?
On Dec 14, 3:10 pm, Dave F wrote: Sub UnhideAll() 'Unhides all rows/columns 'Freezes window at B6 Cells.Select Range("B1").Activate Selection.EntireRow.Hidden = False Selection.EntireColumn.Hidden = False Range("B6").Select ActiveWindow.FreezePanes = False ActiveWindow.FreezePanes = True End Sub This was recorded via the macro recorder and then slightly modified by me. My understanding is that the recorder does not create the most efficient code, but I don't know what's inefficient about this code. Any advice? If it does what you want and does it fast enough then I wouldn't worry about it. If you're dead set on cleaning up the code, then the sequence of Activate, then Select followed by using the Selection object can be compressed. I suppose you might get to something like this, which (from a very quick test) seems to do the same as your recorded code: Sub UnhideAll() 'Unhides all rows/columns 'Freezes window at B6 With Cells .EntireRow.Hidden = False .EntireColumn.Hidden = False End With Range("B6").Select With ActiveWindow .FreezePanes = False .FreezePanes = True End With End Sub HTH, Mike |
All times are GMT +1. The time now is 03:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com