LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Unhide roes in a different worksheet - My code is not working

If you can change you design slightly to give a constant spacing between
these sections (instead of the 43/44 that you have at the moment), you could
do it in a loop:

Private Sub CommandButton2_Click()
Const SPACING As Long = 44

ShowHide Sheet1.Range("Confirmation").Value, SPACING

End Sub

Private Sub ShowHide(SectionCount As Variant, RowSpacing As Long)
Dim i As Long
Dim ShowRows As Boolean
Dim Counter As Long

If IsNumeric(SectionCount) Then
Counter = SectionCount
ShowRows = False
Else
Counter = 5
ShowRows = True
End If

For i = 1 To Counter
Sheet6.Rows(4 + RowSpacing * (i - 1) & ":" & 6 + RowSpacing * (i -
1)).EntireRow.Hidden = ShowRows
'Debug.Print Sheet6.Rows(4 + RowSpacing * (i - 1) & ":" & 6 + RowSpacing
* (i - 1)).Address
Next

End Sub

NickHK

"Ram" wrote in message
oups.com...
Hi,

Basing on values 1to 5 given in a dropdown, I want different rows to
unhide and hide accordingly. I have this code it does not work at
all!!!!

Private Sub Page()
Dim conf
conf = Sheet1.Range("Confirmation").Value

If conf = 1 Then
Sheet6.Rows("4:6").EntireRow.Hidden = False
End If

If conf = 2 Then
Sheet6.Rows("4:6").EntireRow.Hidden = False
Sheet6.Rows("48:50").EntireRow.Hidden = False
End If
If conf = 3 Then
Sheet6.Rows("4:6").EntireRow.Hidden = False
Sheet6.Rows("48:50").EntireRow.Hidden = False
Sheet6.Rows("91:93").EntireRow.Hidden = False
End If
If conf = 4 Then
Sheet6.Rows("4:6").EntireRow.Hidden = False
Sheet6.Rows("48:50").EntireRow.Hidden = False
Sheet6.Rows("91:93").EntireRow.Hidden = False
Sheet6.Rows("134:136").EntireRow.Hidden = False
End If
If conf = 5 Then
Sheet6.Rows("4:6").EntireRow.Hidden = False
Sheet6.Rows("48:50").EntireRow.Hidden = False
Sheet6.Rows("91:93").EntireRow.Hidden = False
Sheet6.Rows("134:136").EntireRow.Hidden = False
Sheet6.Rows("178:180").EntireRow.Hidden = False
End If

If conf = "Select one" Then
Sheet6.Rows("4:6").EntireRow.Hidden = True
Sheet6.Rows("48:50").EntireRow.Hidden = True
Sheet6.Rows("91:93").EntireRow.Hidden = True
Sheet6.Rows("134:136").EntireRow.Hidden = True
Sheet6.Rows("178:180").EntireRow.Hidden = True
End If

End Sub

Some one please help me make modifications to this code or give me
another work around code.
Thanks a lot
Regards,
SRC



 
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
coloured roes static while sorting data ybeckett Excel Discussion (Misc queries) 3 December 4th 09 04:45 PM
My code is still not working -- Excel 2000 Worksheet protection Bill Case Excel Programming 2 September 19th 06 03:56 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
Code not working after worksheet change. Erik Excel Programming 0 September 17th 04 04:01 AM


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