ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can this code be made more efficient? (https://www.excelbanter.com/excel-programming/379424-re-how-can-code-made-more-efficient.html)

Roger Govier

How can this code be made more efficient?
 
Hi Dave

No need to do selection, other than for setting where the freeze panes
is to occur

Try
Sub UnhideAll()
'Unhides all rows/columns
'Freezes window at B6

With ActiveSheet
..Rows.Hidden = False
..Columns.Hidden = False
End With
ActiveWindow.FreezePanes = False
Range("B6").Select
ActiveWindow.FreezePanes = True
End Sub

--
Regards

Roger Govier


"Dave F" wrote in message
...
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?
--
Brevity is the soul of wit.





All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com