#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default Unhide row formula

I am using the following code to hide or unhide rows. How do I get this
formula to perform the activecell functions only when unhide is being
performed?

'Application.EnableEvents = False' not necessary
If Not Application.Intersect(Target, Range("B9")) Is Nothing Then
Rows("10:11").Hidden = IIf(UCase(Range("B9")) = "", True, False) 'spelling
'ActiveCell.Offset(-6, 0).Select
ActiveCell.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
End If
'Application.EnableEvents = False
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Unhide row formula

Drop the IIF stuff and use a regular if/then/else structure.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

'single cell at a time??
If Target.Cells.Count 1 Then Exit Sub

If Intersect(Target, Me.Range("b9")) Is Nothing Then
Exit Sub
End If

Application.EnableEvents = False
If Target.Value = "" Then
Me.Rows("10:11").Hidden = True
Else
Me.Rows("10:11").Hidden = False
Target.End(xlUp).Offset(1, 0).Select
End If
Application.EnableEvents = True

End Sub

I used the worksheet_change event. I'm not sure what event you're using.

ps. the last application.enableevents should be true in your original code.

And with some versions of excel (xl2003 and higher), hiding/unhiding rows will
cause the worksheet to recalculate--and disabling events may be wanted.

And if you're selecting a range, you may want to stop the
worksheet_Selectionchange from firing, too.

It seems like a good thing to keep both those .enableevents lines in your code.

Jeremy wrote:

I am using the following code to hide or unhide rows. How do I get this
formula to perform the activecell functions only when unhide is being
performed?

'Application.EnableEvents = False' not necessary
If Not Application.Intersect(Target, Range("B9")) Is Nothing Then
Rows("10:11").Hidden = IIf(UCase(Range("B9")) = "", True, False) 'spelling
'ActiveCell.Offset(-6, 0).Select
ActiveCell.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
End If
'Application.EnableEvents = False


--

Dave Peterson
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 do I unhide the formula bar Welby Excel Discussion (Misc queries) 1 December 22nd 09 11:41 PM
unhide row does not unhide the hidden rows nikita Excel Worksheet Functions 4 May 24th 08 02:59 PM
How do I unhide the formula bar? Lorin Excel Discussion (Misc queries) 2 April 24th 06 09:22 PM
how do i unhide a worksheet in excel 2003? unhide tab don't work mikekeat Excel Discussion (Misc queries) 2 March 6th 06 03:36 AM
How do I unhide a column when format/column/unhide won't work lincolnblaze Excel Worksheet Functions 1 December 14th 05 03:38 AM


All times are GMT +1. The time now is 11:29 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"