Alternative to Select Case

Status
Not open for further replies.

caet_

New Member
Joined
Nov 22, 2020
Messages
28
Office Version
  1. 2016
Platform
  1. Windows
Hello all!

I hope to find you well. Once again, this newbie to VBA will ask for your help.

I would like to hide certain rows, based on a form control checked or not checked. In sheet "Part1", one will select, in column A, which Products they own (can be more than one).
On the sheet "Part2", the rows related to the product that were not "checked" should be hidden.

I have tried to use this code. However, I believe that select case is not the most suitable for what I want, as it does not work.:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("AC5, AC6, AC7, AC8")) Is Nothing Then Exit Sub
ActiveSheet.Unprotect Password:="123"
Application.ScreenUpdating = False
With Sheets("Part2")
Select Case Target.Address
Case "$AC$5"
Select Case Target.Value
Case Is = 0
.Rows("5").EntireRow.Hidden = True
End Select
Case "$AC$6"
Select Case Target.Value
Case Is = 0
.Rows("6").EntireRow.Hidden = True
End Select
Case "$AC$7"
Select Case Target.Value
Case Is = 0
.Rows("7").EntireRow.Hidden = True
End Select
Case "$AC$8"
Select Case Target.Value
Case Is = 0
.Rows("8").EntireRow.Hidden = True
End Select
End Select
ActiveSheet.Protect Password:="123"
Application.ScreenUpdating = True
End With
End Sub

You can find the excel file here, if it helps: question.xlsm

Thank you in advance!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Duplicate to: Hide rows in a sheet according to selections on another sheet

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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
Back
Top