LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default hide empty rows on open

Hi,

I have a spreadsheet that has cell references to another spreadsheet.
I am trying to write a macro script that when the document is opened
(and refreshes data from the linked spreadsheet) it looks at the rows
which are blank and hides these rows.

So far I have found the following code below which works great,
however this macro re-runs everytime you navigate back to the
worksheet, causing the screen to flicker for a few seconds.

Private Sub Worksheet_Activate()
Dim rng As Range, cell As Range
Set rng = Application.Intersect(ActiveSheet.UsedRange, Range
("B6:G120"))
For Each cell In rng
If Application.CountA(cell.EntireRow) = 0 Then cell.EntireRow.Hidden =
True
Next
Application.ScreenUpdating = True
End Sub


I just want the script to run once.

I have tried replacing the top line of script with:


Private Sub Worksheet_Change(ByVal Target As Range)


However I was then getting a debug error associated with line 3.

Can anybody offer any help?

Thanks in advance!
 
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 i auto hide empty rows in printing in excel? TM Excel Discussion (Misc queries) 3 August 1st 08 07:42 PM
Is there a way to automatically hide empty rows? Christine Excel Worksheet Functions 1 April 12th 07 10:22 PM
Hide Empty Rows When Printing Bob Excel Worksheet Functions 5 August 20th 05 12:57 PM
Format to hide empty rows tamato43 Excel Discussion (Misc queries) 4 May 10th 05 10:16 PM
Macro to hide rows with empty cells tp58tp Excel Worksheet Functions 2 November 13th 04 02:01 PM


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

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

About Us

"It's about Microsoft Excel"