Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old June 12th 12, 09:23 AM
Junior Member
 
First recorded activity by ExcelBanter: Jun 2012
Location: Pretoria, South Africa
Posts: 2
Question Help - hiding multiple sets of rows based on two different cells

Please help. I have two cells on say Sheet 1 (cell C9 and cell C11). If cell C9 < 0.01, then I want to hide rows 56:64 on Sheet2. At the same time, if cell C11 < 0.01, I want to hide rows 65:78 on sheet 2). I have compiled something based on what I read on the threads, but the second IF seems to override the first IF e.g. If I type in ‘0’ in cell C9, it hides rows 56:64 on Sheet2, which is correct. However, when I proceed and type in ‘0’ in cell C11, it un-hides rows 56:64, even though cell C9 is still ‘0’. This is what I have written:

Sub Worksheet_Change(ByVal Target As Range)
If (Target.Row = 9) And (Target.Column = 3) And _
(Target < 0.01) Then
Worksheets("Report").Rows("51:64").Rows.Hidden = True
Else
Worksheets("Report").Rows("51:64").Rows.Hidden = False
End If
If (Target.Row = 11) And (Target.Column = 3) And _
(Target < 0.01) Then
Worksheets("Report").Rows("65:78").Rows.Hidden = True
Else
Worksheets("Report").Rows("65:78").Rows.Hidden = False
End If
End Sub

Please help, what am I doing wrong?

Thanks

Andre

  #2   Report Post  
Old June 12th 12, 02:51 PM posted to microsoft.public.excel.newusers
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2011
Posts: 3,689
Default Help - hiding multiple sets of rows based on two different cells

Hi Andre,

Am Tue, 12 Jun 2012 08:23:25 +0000 schrieb Andredprz:

Please help. I have two cells on say Sheet 1 (cell C9 and cell C11).
If cell C9 < 0.01, then I want to hide rows 56:64 on Sheet2. At the
same time, if cell C11 < 0.01, I want to hide rows 65:78 on sheet 2). I
have compiled something based on what I read on the threads, but the
second IF seems to override the first IF e.g. If I type in
‘0’ in cell C9, it hides rows 56:64 on Sheet2, which is
correct. However, when I proceed and type in ‘0’ in cell
C11, it un-hides rows 56:64, even though cell C9 is still
‘0’.


try:

Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case Is = "$C$9"
Worksheets("Report").Rows("51:64").Rows.Hidden _
= Target < 0.01
Case Is = "$C$11"
Worksheets("Report").Rows("65:78").Rows.Hidden _
= Target < 0.01
End Select
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Old June 13th 12, 08:41 AM
Junior Member
 
First recorded activity by ExcelBanter: Jun 2012
Location: Pretoria, South Africa
Posts: 2
Thumbs up

Clause, thank you so much! It works perfectly!

Thanks

Andre


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
Counting rows based on the contents of multiple cells Bret[_2_] Excel Worksheet Functions 2 August 11th 09 09:26 PM
Multiple cells hiding rows, changing print area timmtamm Excel Programming 0 February 10th 09 12:33 AM
Rows to columns with multiple sets chrisL Excel Worksheet Functions 1 December 8th 08 07:35 PM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Counting rows based on criteria in multiple cells Margaret Excel Discussion (Misc queries) 11 December 2nd 04 11:04 PM


All times are GMT +1. The time now is 10:21 AM.

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

About Us

"It's about Microsoft Excel"

 

Copyright © 2017