Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Hide rows using VBA based on cell value

I have also posted this in another group by mistake. Apologies.


Hi,

I have various drop downs on a worksheet. What I want to do is if the
value of B3 is 2 then unhide rows 4 & 5 along with drop down 7 and
drop down 8. If the value of B3 isn't 2 then hide the rows and drop
downs. I also want to do the same thing with rows 15-18 and drop
downs
3, 4,5 if the value of B14 is 2 etc. I can get it to work fine for
one
of these with this code:


================================================== ====================


Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False


With Sheets("form")


If Range("B14").Value = 2 Then
Rows("15:18").EntireRow.Hidden = False
ActiveSheet.Shapes("Drop Down 3").Visible = True
ActiveSheet.Shapes("Drop Down 4").Visible = True
ActiveSheet.Shapes("Drop Down 5").Visible = True


Else
Rows("15:18").EntireRow.Hidden = True
ActiveSheet.Shapes("Drop Down 3").Visible = False
ActiveSheet.Shapes("Drop Down 4").Visible = False
ActiveSheet.Shapes("Drop Down 5").Visible = False
End If


End With


End Sub


================================================== ========================


but when I adapt the above code to include the other option, so my
code reads:


================================================== ====================


Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False


With Sheets("form")


If Range("B3").Value = 2 Then
Rows("4:5").EntireRow.Hidden = False
ActiveSheet.Shapes("Drop Down 7").Visible = True
ActiveSheet.Shapes("Drop Down 8").Visible = True


Else
Rows("4:5").EntireRow.Hidden = True
ActiveSheet.Shapes("Drop Down 7").Visible = False
ActiveSheet.Shapes("Drop Down 8").Visible = False
End If


If Range("B14").Value = 2 Then
Rows("15:18").EntireRow.Hidden = False
ActiveSheet.Shapes("Drop Down 3").Visible = True
ActiveSheet.Shapes("Drop Down 4").Visible = True
ActiveSheet.Shapes("Drop Down 5").Visible = True


Else
Rows("15:18").EntireRow.Hidden = True
ActiveSheet.Shapes("Drop Down 3").Visible = False
ActiveSheet.Shapes("Drop Down 4").Visible = False
ActiveSheet.Shapes("Drop Down 5").Visible = False
End If


End With


End Sub


================================================== ========================


it seems to be looping or recalculating over and over and I have to
hit Esc to get it to stop.


I can't work out why it can do one set fine but not 2.


Can anyone help?


Thanks


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
Hide Rows based on value of a cell Gordon[_2_] Excel Programming 2 September 25th 08 01:10 PM
Hide Rows Based on Cell Result BJ Excel Programming 2 April 14th 08 11:41 PM
hide rows based on cell value dummster New Users to Excel 1 February 15th 06 11:37 PM
hide rows based on value in cell dummster Excel Discussion (Misc queries) 0 February 15th 06 03:27 PM
How to Hide Rows based on conditional value in cell Nick Excel Programming 1 May 21st 04 11:16 AM


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