vandango05
Board Regular
- Joined
- Oct 6, 2008
- Messages
- 110
Hi
I've used the forum to create some code that hides particular rows based on a validation list in cell C6 here is the code:
Private Sub Worksheet_Calculate()
Dim MyResult As String
Application.EnableEvents = False
Rows("1:" & Worksheets("Cutting Sheet for Std Systems").UsedRange.Rows.Count).EntireRow.Hidden = False
MyResult = Worksheets("Cutting Sheet for Std Systems").Cells(6, 3).Value
Select Case MyResult
Case "XO", "XX", "OX"
Rows("28:33").EntireRow.Hidden = True
Rows("36").EntireRow.Hidden = True
Rows("38").EntireRow.Hidden = True
Rows("44:49").EntireRow.Hidden = True
Rows("50:67").EntireRow.Hidden = True
Rows("72").EntireRow.Hidden = True
Rows("86:91").EntireRow.Hidden = True
Case "XXP"
Rows("29:33").EntireRow.Hidden = True
Rows("38").EntireRow.Hidden = True
Rows("45:49").EntireRow.Hidden = True
Rows("51").EntireRow.Hidden = True
Rows("53:55").EntireRow.Hidden = True
Rows("57").EntireRow.Hidden = True
Rows("59:61").EntireRow.Hidden = True
Rows("63").EntireRow.Hidden = True
Rows("65:67").EntireRow.Hidden = True
Rows("72").EntireRow.Hidden = True
Rows("87:91").EntireRow.Hidden = True
' (repeated for further cases or configurations, but deleted to shrink post)
End Select
Application.EnableEvents = True
End Sub
I have a couple of problems with it. The code works fine but I also need to add in to hide other rows based on values in C10, C11, C12 and some others. I have tried amending the code within a new event but it stops the first part of code working.
A second problem is that the undo function is no longer available when the code is inserted in the worksheet.
Finally the third problem is that when this is used my colleague who i'm making it for will probably rename the worksheet (despite me saying that he can't!)
Any ideas and help would be greatly appreciated.
I've used the forum to create some code that hides particular rows based on a validation list in cell C6 here is the code:
Private Sub Worksheet_Calculate()
Dim MyResult As String
Application.EnableEvents = False
Rows("1:" & Worksheets("Cutting Sheet for Std Systems").UsedRange.Rows.Count).EntireRow.Hidden = False
MyResult = Worksheets("Cutting Sheet for Std Systems").Cells(6, 3).Value
Select Case MyResult
Case "XO", "XX", "OX"
Rows("28:33").EntireRow.Hidden = True
Rows("36").EntireRow.Hidden = True
Rows("38").EntireRow.Hidden = True
Rows("44:49").EntireRow.Hidden = True
Rows("50:67").EntireRow.Hidden = True
Rows("72").EntireRow.Hidden = True
Rows("86:91").EntireRow.Hidden = True
Case "XXP"
Rows("29:33").EntireRow.Hidden = True
Rows("38").EntireRow.Hidden = True
Rows("45:49").EntireRow.Hidden = True
Rows("51").EntireRow.Hidden = True
Rows("53:55").EntireRow.Hidden = True
Rows("57").EntireRow.Hidden = True
Rows("59:61").EntireRow.Hidden = True
Rows("63").EntireRow.Hidden = True
Rows("65:67").EntireRow.Hidden = True
Rows("72").EntireRow.Hidden = True
Rows("87:91").EntireRow.Hidden = True
' (repeated for further cases or configurations, but deleted to shrink post)
End Select
Application.EnableEvents = True
End Sub
I have a couple of problems with it. The code works fine but I also need to add in to hide other rows based on values in C10, C11, C12 and some others. I have tried amending the code within a new event but it stops the first part of code working.
A second problem is that the undo function is no longer available when the code is inserted in the worksheet.
Finally the third problem is that when this is used my colleague who i'm making it for will probably rename the worksheet (despite me saying that he can't!)
Any ideas and help would be greatly appreciated.