Solved

Else IF Statement that uses text

Posted on 2014-12-23
1
152 Views
Last Modified: 2014-12-23
Hi,

I would need rows "32:37" to collapse if cell "B33" did not equal to "Mail Form to:"
If they did equal "Mail Form to:", then they would expand

Below is the code I am using

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngIntersect As Range
Set rngIntersect = Intersect(Target, Range("$A$12:$A$1500"))

If Not rngIntersect Is Nothing Then

    If Range("C24").Value = 0 Then
        Rows("24:29").EntireRow.Hidden = True
    Else
        Rows("24:29").EntireRow.Hidden = False
    End If
    
    If Range("C23").Value = 0 Then
        Rows("23").EntireRow.Hidden = True
    Else
        Rows("23").EntireRow.Hidden = False
    End If

    If Range("C39").Value = 0 And Range("C40").Value = 0 Then
            'both ranges are zero, hide rows 30-35
            Rows("38:47").EntireRow.Hidden = True
        ElseIf Range("C40").Value > 0 Then
            'range > 0, display rows 32-35
            Rows("40:47").EntireRow.Hidden = False
            Rows("38").EntireRow.Hidden = False
            'hide row 31
            Rows("39").EntireRow.Hidden = True
        ElseIf Range("C39").Value > 0 Then
            'range > 0, display row 31
            Rows("38:39").EntireRow.Hidden = False
            'hide rows 32-35
            Rows("40:45").EntireRow.Hidden = True
        Else
            'display rows 30-35
            Rows("38:47").EntireRow.Hidden = False
        End If
        
    If Range("C49").Value = 0 And Range("C50").Value = 0 Then
            Rows("48:57").EntireRow.Hidden = True
        ElseIf Range("C49").Value > 0 Then
            Rows("50:55").EntireRow.Hidden = True
            Rows("48:49").EntireRow.Hidden = False
        ElseIf Range("C50").Value > 0 Then
            Rows("50:57").EntireRow.Hidden = False
            Rows("49").EntireRow.Hidden = True
        Else
            Rows("48:57").EntireRow.Hidden = False
        End If
End If

End Sub

Open in new window

0
Comment
Question by:Boston617
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 34

Accepted Solution

by:
ste5an earned 500 total points
ID: 40515073
So, what is your question??

Rows("32:37").EntireRow.Hidden = (Range("B44").Value <> "Mail Form to:")

Open in new window


btw, it seems that we are talking about row visbility. Collapse and expand means grouping or pivot tables.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question