Unhide rows in Excel with VBA

0 votes

I'm trying to use the following code in Excel, but it is not working. Cell AE25 refers to a cell using data validation to pull the numbers 1-8 from a list.

Select Case Range("AE25").Value
   Case 1
      Range("A26:A28").EntireRow.Hidden = False
   Case 2
      Range("A26:A29").EntireRow.Hidden = False
   Case 3
      Range("A26:A30").EntireRow.Hidden = False
   Case 4
      Range("A26:A31").EntireRow.Hidden = False
   Case 5
      Range("A26:A32").EntireRow.Hidden = False
   Case 6
      Range("A26:A33").EntireRow.Hidden = False
   Case 7
      Range("A26:A34").EntireRow.Hidden = False
   Case 8
      Range("A26:A35").EntireRow.Hidden = False
End Select
Sep 30, 2022 in Others by Kithuzzz
• 38,010 points
569 views

1 answer to this question.

0 votes

Paste this code into a module of the sheet where your data are, e.g. you have data in 'Sheet1', then paste it to the 'Sheet1' class module. HTH.

Private Sub Worksheet_Change(ByVal Target As Range)
    ' AE25
    If (Not Intersect(Target, Range("AE25")) Is Nothing) Then
        Select Case Target.Value
            Case 1
                Range("A26:A28").EntireRow.Hidden = False
            Case 2
                Range("A26:A29").EntireRow.Hidden = False
            Case 3
                Range("A26:A30").EntireRow.Hidden = False
            Case 4
                Range("A26:A31").EntireRow.Hidden = False
            Case 5
                Range("A26:A32").EntireRow.Hidden = False
            Case 6
                Range("A26:A33").EntireRow.Hidden = False
            Case 7
                Range("A26:A34").EntireRow.Hidden = False
            Case 8
                Range("A26:A35").EntireRow.Hidden = False
            Case Else
                ' hide all rows 26-35 if value is not equal to 1-8
                Range("A26:A35").EntireRow.Hidden = True
        End Select
    End If

    ' Z40
    If (Not Intersect(Target, Range("Z40")) Is Nothing) Then
        Select Case Target.Value
            Case "PowerPoint", "Verbal"
                Range("A41").EntireRow.Hidden = False
            Case "None"
                Range("A41").EntireRow.Hidden = True
            Case Else

        End Select
    End If
End Sub

enter image description here

answered Oct 1, 2022 by narikkadan
• 63,420 points

Related Questions In Others

0 votes
0 answers

Convert Rows to Columns with values in Excel using custom format

1 I having a Excel sheet with 1 ...READ MORE

Feb 17, 2022 in Others by Edureka
• 13,670 points
699 views
0 votes
1 answer

Create unique rows in Excel with limited data to be used in multiple columns

This setup isn't readily generalizable, though since ...READ MORE

answered Oct 14, 2022 in Others by narikkadan
• 63,420 points
503 views
0 votes
1 answer

How to draw wedge shape with outline in Excel VBA?

According to https://learn.microsoft.com/en-us/office/vba/api/excel.adjustments: Because each adjustable shape has a ...READ MORE

answered Dec 25, 2022 in Others by narikkadan
• 63,420 points
293 views
0 votes
1 answer

How can I count the rows with data in an Excel sheet?

With formulas, what you can do is: in ...READ MORE

answered Dec 27, 2022 in Others by narikkadan
• 63,420 points
345 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
877 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,183 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
481 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
731 views
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,420 points
819 views
0 votes
1 answer

Deleting Empty rows in Excel using VBA

On Error Resume Next worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete On Error GoTo 0 When ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 63,420 points
993 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP