VBA to hide groups of rows based on cell values

paolid

New Member
Joined
Apr 26, 2023
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi, I've created a form in excel that requires certain rows to be hidden or visible based on cell value and I've no clue how I can build out a code to do this. I wish I understood them more.........

Frustratingly I had created the form in Microsoft Forms but it isn't suitable as only allows one user to complete the form whereas mine will probably need input from several team members and needs to be fluid.
I'm hoping a code to auto hide or make rows visible will make it more user friendly.

This is what I need to achieve if anyone out there can help at all?

Beginning

If cell K26 is "Yes" or blank, then rows 27:106 need to be hidden. If "No" then rows 27:35 need to be visible and rows 36:106 hidden.


If cell K35 is "Yes", then rows 37:44 need to be visible with rows 36 and 45:106 hidden, if "no" then rows 36 needs to be visible with 37:106 hidden

If cell K36 is "Yes" then rows 37:67 and rows 82:106 need to be hidden. If "no" then rows 37:106 hidden


If cell K43 is "Yes", then rows 45:51 need to be visible with rows 44 and 53:106 hidden, if "no" then rows 44 needs to be visible with 45:106 hidden

If cell K44 is "Yes" then rows 45:67 and rows 82:106 need to be hidden. If "no" then rows 45:106 hidden


If cell K51 is "Yes", then rows 53:59 need to be visible with rows 52 and 61:106 hidden, if "no" then rows 52 needs to be visible with 53:106 hidden

If cell K52 is "Yes" then rows 53:67 and rows 82:106 need to be hidden. If "no" then rows 53:106 hidden


If cell K59 is "Yes", then rows 61:67 need to be visible with rows 60 and 69:106 hidden, if "no" then rows 60 needs to be visible with 61:106 hidden

If cell K60 is "Yes" then rows 61:67 and rows 82:106 need to be hidden. If "no" then rows 61:106 hidden


If cell K67 is "Yes", then rows 68:80 need to be visible with rows 81:106 hidden, if "no" rows 68:106 hidden

If cell K80 is "Yes", then rows 81:93 need to be visible with rows 94:106 hidden, if "no" rows 81:106 hidden

If cell K93 is "Yes", then rows 94:106 need to be visible, if "no" rows 94:106 hidden

End

I'm not sure if it would be easier to group the rows which make up the sections into tables? But there's still the anomaly of where K44 will only show if K43 is "no" I don't know how that would work as a table.

If anyone can help me I'll be eternally grateful - thank you.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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