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

Dan Swartz

New Member
Joined
Apr 17, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Watch MrExcel Video

Forum statistics

Threads
1,122,437
Messages
5,596,112
Members
414,042
Latest member
Swiftkoala

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