Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can this code be made more efficient? Bob Phillips Excel Programming 0 December 14th 06 03:17 PM
Efficient Code GregR Excel Programming 7 June 27th 05 04:09 PM
More Efficient code than this thom hoyle Excel Programming 14 May 11th 05 07:40 AM
Can this procedure be made more efficient? DennisE Excel Programming 7 April 26th 04 09:55 AM
More efficient code Rob Bovey Excel Programming 1 July 9th 03 04:46 AM


All times are GMT +1. The time now is 08:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"