hide/show rows when cells in Column A are blank - based on data validation drop down list in a cell

Yodelayheewho

New Member
Joined
Jun 23, 2017
Messages
13
Hello,

I have searched the threads and cannot find the solution that fits my situation.

I have a worksheet with a data validation drop down menu in E3. This list is comprised of four types of services: Service 1, Service 2, Service 3, Service 4.

For each service, there is a unique set of tools, products and auxiliary items needed to complete the service.

Service 1 has 3 rows of tools, 3 rows of products and no auxiliary items
Service 2 has 3 rows of tools, 3 rows of products and no auxiliary items
Service 3 has 8 rows of tools, 5 rows of products and 9 rows of auxiliary items
Service 4 has 8 rows of tools, 5 rows of products and 9 rows of auxiliary items

I understand I can't accomplish what I need with a formula. So, I need to create a simple VBA (I'm a novice) that automatically hides/shows rows based on the drop down selection made in E3.

I apologize if I've not posted this correctly.

I appreciate any assistance you would provide.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Sorry for my delayed response.
AAArqcthOGUHYQtN30hlK1Apa


The attached screen shots show Service 1 and Service 3. You really only need to focus on Column A since I removed proprietary information in the other columns. Notice that for Service 1 I had to put a note in the Auxiliary Section to let users know there are no Auxiliary items for Service 1, but Service 3 there is, which you can see in the second screen shot. What I would prefer is to have all rows hide if the cell in Column A is blank.
AAArqcthOGUHYQtN30hlK1Apa
 
Upvote 0
If you shared the actual mockup in excel it would have been easier but that's for next time.. :-)

try this:

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim rSelect As Range

Set rSelect = Intersect(Target, Range("E3"))
If Not rSelect Is Nothing Then
    Application.EnableEvents = False
        Select Case rSelect '1 line hide all rows in the section, 2nd line shows necesarry lines
            Case Is = "Service 1", "Service 2"
                'Next 2 lines show or hide tooling section
                Rows("6:13").EntireRow.Hidden = True
                Rows("6:8").EntireRow.Hidden = False
                'Next 2 lines show or hide product section
                Rows("18:22").EntireRow.Hidden = True
                Rows("18:20").EntireRow.Hidden = False
                'Next 2 lines show or hide aux section
                Rows("24:32").EntireRow.Hidden = True
            Case Is = "Service 3", "Service 4"
                'Next line show tooling section
                Rows("6:13").EntireRow.Hidden = False
                'Next line show product section
                Rows("18:22").EntireRow.Hidden = False
                'Next line show aux section
                Rows("24:32").EntireRow.Hidden = False
        End Select
    
End If

This VBA code needs to be copied onto the code page of the worksheet so not in a separate module.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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