View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 1,726
Default How can this code be made more efficient?

Selecting is not efficient, and working on all cells is a bad idea

Sub UnhideAll()
'Unhides all rows/columns
'Freezes window at B6
Range(Range("B1"), Range("B1").End(xlDown)).EntireRow.Hidden = False
Range(Range("B1"), Range("B1").End(xlToRight)).EntireColumn.Hidden =
False
Range("B6").Select
ActiveWindow.FreezePanes = False
ActiveWindow.FreezePanes = True
End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"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.