Hide and Unhide rows based on two values in two columns

Status
Not open for further replies.

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hi All

Please help i have values in column 8 and column 9, where in if column 8 issue type is selected with item1 column 9 will be visible and column 9 has three values in it so if column 9 (product) is selected with soap rows 21 should be visible, like vise there are three other values in column 9 as well for which rows should hide and unhide based on the selection, i have tried the below code so only column 8 works.

also note column 8 has 8 other values based on which rows are hidden and unhidden which is working fine for me.

please help when there is column 8 with issue type selected with item 1 column 9 unhides and column 9 has three other options where in the rows needs to be also hidden and unhidden


Private Sub Worksheet_Change(ByVal Target As Range)
If Range("Issue type").Value = "Item1" And Range("Product").Value = "Soap" Then
Rows(8).Hidden = False
Rows(21).Hidden = False
Rows(19).Hidden = False
Rows("9:18").Hidden = True
Rows(20).Hidden = True
If Range("Issue type").Value = "Item1" And Range("Product 2").Value = "Box" Then
Rows(8).Hidden = False
Rows(23).Hidden = False
Rows(19).Hidden = False
Rows("9:18").Hidden = True
Rows(20).Hidden = True
ElseIf Target.Value = "Item 2" Then
Rows(10).Hidden = False
Rows(16).Hidden = False
Rows(21).Hidden = False
Rows(9).Hidden = False
Rows(15).Hidden = False
Rows("11:14").Hidden = True
Rows("17:20").Hidden = True
'ElseIf Target.Value = "Item 3" Then
'Rows("9:21").Hidden = False
'Rows("19:20").Hidden = True
'Rows(8).Hidden = True
ElseIf Target.Value = "Item 4" Then
Rows("8:19").Hidden = True
Rows("20:21").Hidden = False
Rows(15).Hidden = False
ElseIf Target.Value = "Item 5" Then

End if
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Status
Not open for further replies.

Forum statistics

Threads
1,141,773
Messages
5,708,453
Members
421,570
Latest member
BaileyJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top