Mike Woodhouse
12/14/2006 3:24:00 PM
On Dec 14, 3:10 pm, Dave F <D...@discussions.microsoft.com> 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