Hiding Rows based on cell value using a private sub by value

Dan Swartz

Board Regular
Joined
Apr 17, 2020
Messages
51
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm new here. I have asked this on several other forms and I have not received an answer. I'm also not sure how to ask this as it's pretty complicated. I'll try and keep it on the vague side. I'll upload an image.

The setup:
1. I use conditional formatting using MOD(ROW(),2)=0 to alternate color of cells from B7 to M99.
2. I have a list of questions in column A with Answers in column B and more information in the following columns. If the answer in Column B is "None", then I automatically want to hide that row. Also, "None" Is selected from a dropdown and so if I accidentally select none, then I need to manually be able to unhide the row so I can change the value to the proper value.

What I have right now it working, but I have 3 issues.

Issue 1. When a row is hidden, I no longer have alternating colors on my rows.
Issue 2. If I do multiple selections and delete, or insert a row or do any editing on more then one cell. I get the "Run TIme Error 13 - Type Mismatch"
Issue 3. I have a formula, where if one value says none, then i'm turning the following 6 lines to None, but it won't hide those rows unless I double click in the cell and hit enter.

I hope this is clear enough to get answers.

Here is my code.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange, N As Range

Set MyRange = Range("B8:B90")

If Not Application.Intersect(Target, MyRange) Is Nothing Then

If Target.Value = "N/A" Then
Target.EntireRow.Hidden = True
Else
Target.EntireRow.Hidden = False
End If

End If

End Sub

Sample Spreadsheet.png
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,214,400
Messages
6,119,292
Members
448,885
Latest member
LokiSonic

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