Good Day Everyone.
I am working on reformatting some of our quality control documents. The current document I am working on has rows hidden to clean up unused data cells. As my crews go through a particular piece of equipment and select what is installed, portions of these rows are unhidden. The code I wrote works but seems a bit cumbersome as I would like to implement this in greater detail for some of our other documents. My primary goal is to keep unused data entry points hidden to minimize the number of sheets required when we go to print off the document. Below is the code, let me know your thoughts and whether or not it can be cleaned up or simplified.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("I16").Value = "Yes" Or Range("Y16").Value = "Yes" Then
Rows("18").EntireRow.Hidden = False
Rows("27").EntireRow.Hidden = False
Rows("34").EntireRow.Hidden = False
Rows("51:52").EntireRow.Hidden = True
ElseIf Range("I16").Value = "" Or Range("I16").Value = "No" And Range("Y16").Value = "" Or Range("Y16").Value = "No" Then
Rows("18").EntireRow.Hidden = True
Rows("27").EntireRow.Hidden = True
Rows("51:52").EntireRow.Hidden = False
End If
If Range("I16").Value = "Yes" Then
Rows("19:22").EntireRow.Hidden = False
ElseIf Range("I16").Value = "" Or Range("I16").Value = "No" Then
Rows("19:22").EntireRow.Hidden = True
End If
If Range("Y16").Value = "Yes" Then
Rows("23:26").EntireRow.Hidden = False
ElseIf Range("Y16").Value = "" Or Range("Y16").Value = "No" Then
Rows("23:26").EntireRow.Hidden = True
End If
End Sub
Please forgive me as I can not remember how to properly insert the code in a thread.
Thanks for your time and comments.
I am working on reformatting some of our quality control documents. The current document I am working on has rows hidden to clean up unused data cells. As my crews go through a particular piece of equipment and select what is installed, portions of these rows are unhidden. The code I wrote works but seems a bit cumbersome as I would like to implement this in greater detail for some of our other documents. My primary goal is to keep unused data entry points hidden to minimize the number of sheets required when we go to print off the document. Below is the code, let me know your thoughts and whether or not it can be cleaned up or simplified.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("I16").Value = "Yes" Or Range("Y16").Value = "Yes" Then
Rows("18").EntireRow.Hidden = False
Rows("27").EntireRow.Hidden = False
Rows("34").EntireRow.Hidden = False
Rows("51:52").EntireRow.Hidden = True
ElseIf Range("I16").Value = "" Or Range("I16").Value = "No" And Range("Y16").Value = "" Or Range("Y16").Value = "No" Then
Rows("18").EntireRow.Hidden = True
Rows("27").EntireRow.Hidden = True
Rows("51:52").EntireRow.Hidden = False
End If
If Range("I16").Value = "Yes" Then
Rows("19:22").EntireRow.Hidden = False
ElseIf Range("I16").Value = "" Or Range("I16").Value = "No" Then
Rows("19:22").EntireRow.Hidden = True
End If
If Range("Y16").Value = "Yes" Then
Rows("23:26").EntireRow.Hidden = False
ElseIf Range("Y16").Value = "" Or Range("Y16").Value = "No" Then
Rows("23:26").EntireRow.Hidden = True
End If
End Sub
Please forgive me as I can not remember how to properly insert the code in a thread.
Thanks for your time and comments.