need VBA macro for hide the rows based on drop down.

abhisharma1

New Member
Joined
Sep 5, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi Team,

I need vba macro to hide the rows based on drop down values. If the value is Simple in drop down it should hide the rows from 34 to 41 and if we select other values that it should not hide the rows.

Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet
If Target.Address = "$C$17" Then


ase False
Simple = Target.Value
c = 29
Do
erh = True
If .Cells(c, "C") = Simple Then erh = False
.Rows(c - 3 & ":" & c).EntireRow.Hidden = erh
c = c + 4
Loop Until .Cells(c, "C") = Empty
End If
End With
ase True
End Sub

Private Sub ase(ss)
With Application
.EnableEvents = ss
.ScreenUpdating = ss
End With
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi

So if C17 is "Simple" then hide rows 34 to 41, otherwise they should be visible?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("C17")) Is Nothing Then
    Rows("34:41").Hidden = Target.Value = "Simple"
End If
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

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