I'm trying to have a range of two cells (C31-32) that when both equal 0, a certain amount of cells collapse. I also have it so that certain cells inside it collapse or expand if they are greater or equal 0 as well. Below is the code I'm using, in bold is the code i'm trying to work with

Also, I keep getting an error message of "Run-time error '13':Type Mismatch", what does this mean and how do I deal with it?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)If Not Intersect(Target, Range("$A$12:$A$1500")) Then If Range("C24").Value = 0 Then Rows("24:27").EntireRow.Hidden = True Else Rows("24:27").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("C32").Value = 0 Then Rows("32:35").EntireRow.Hidden = True Else Rows("32:35").EntireRow.Hidden = False End If If Range("C31").Value = 0 Then Rows("31").EntireRow.Hidden = True Else Rows("31").EntireRow.Hidden = False End If [b] If Range("C31, C32").Value = 0 Then Rows("30:35").EntireRow.Hidden = True Else Rows("30:35").EntireRow.Hidden = False End If[/b]End IfEnd Sub

try this...replace the section you have with what's below. If Range("C31").Value = 0 AND Range("C32").Value = 0Then
Rows("30:35").EntireRow.Hidden = True
Else
Rows("30:35").EntireRow.Hidden = False
End If

You mean the if statements don't work anymore? Or do you mean that your code doesn't do what you intend it to do?

Follow the logic in your code and you should be able to figure it out. Perhaps you don't need those prior if statements? It's hard for me to know without knowing what it is you're trying to do. See my comments in your code below.

Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("$A$12:$A$1500")) Then If Range("C24").Value = 0 Then Rows("24:27").EntireRow.Hidden = True Else Rows("24:27").EntireRow.Hidden = False End If If Range("C23").Value = 0 Then Rows("23").EntireRow.Hidden = True Else Rows("23").EntireRow.Hidden = False End If 'checking for c32 = 0 here If Range("C32").Value = 0 Then Rows("32:35").EntireRow.Hidden = True Else Rows("32:35").EntireRow.Hidden = False End If 'checking for c31 = 0 here If Range("C31").Value = 0 Then Rows("31").EntireRow.Hidden = True Else Rows("31").EntireRow.Hidden = False End If 'checking for c31 is 0 again and checking for c32 is 0 again. Do you need the prior to if statements? If Range("C31").Value = 0 and Range("C32").Value = 0 Then Rows("30:35").EntireRow.Hidden = True Else Rows("30:35").EntireRow.Hidden = False End If End IfEnd Sub

I need cells C30:C35 to collapse if both C31 and C32 are zero.
Rows 32-35 would need to collapse if C31>0
and only Row 31 would need to collapse if C32>0

What are you trying to do with intersect?
To check if target is in the range you defined?

If so, then code should be better as follows.
Then you will need to click in range A12:A1500 for your code to run.

Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("$A$12:$A$1500")) Is Nothing Then Rows("24:27").EntireRow.Hidden = Range("C24").Value = 0 Rows("23").EntireRow.Hidden = Range("C23").Value = 0 Rows("32:35").EntireRow.Hidden = Range("C32").Value = 0 Rows("31").EntireRow.Hidden = Range("C31").Value = 0 Rows("30:35").EntireRow.Hidden = Range("C31").Value2 = 0 And Range("C32").Value2 = 0 End IfEnd Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("$A$12:$A$1500")) Then If Range("C24").Value = 0 Then Rows("24:27").EntireRow.Hidden = True Else Rows("24:27").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("C31").Value = 0 and Range("C32").Value = 0 Then 'both ranges are zero, hide rows 30-35 Rows("30:35").EntireRow.Hidden = True Elseif Range("C32").Value > 0 then 'range > 0, display rows 32-35 Rows("32:35").EntireRow.Hidden = False 'hide row 31 Rows("31").EntireRow.Hidden = true elseif range("c31").value > 0 then 'range > 0, display row 31 Rows("31").EntireRow.Hidden = False 'hide rows 32-35 Rows("32:35").EntireRow.Hidden = true else 'display rows 30-35 Rows("30:35").EntireRow.Hidden = False End If End IfEnd Sub

The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a â€¦

Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaacâ€¦