Hi,
Have what I hope is a simple problem!
I am trying to create a spreadsheet which unhides certain rows based on what a user enters into a cell (Section 1 the cell is F20, Section 2 the cell is F40).
I have got this to work for one section, but when adding a second section it is returning a "Else Without If" error on the third line of code.
Appreciate if someone could tell me where I am going wrong!
Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("F20"), Target) Is Nothing Then Call Section1Code(Target)
ElseIf Not Application.Intersect(Range("F40"), Target) Is Nothing Then Call Section2Code(Target)
End If
End Sub
'Section 1
Sub Section1Code(Target As Range)
Range("A22:A130").EntireRow.Hidden = True
If Range("E7").Value = "" Then
MsgBox ("You need to enter a valuebefore you can proceed")
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Else
If Range("E8").Value = "" Then
MsgBox ("You need to enter a value before you can proceed")
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Else
If Target.Value = "Yes" Then
Range("A22:A46").EntireRow.Hidden = False
End If
End If
End If
End Sub
'Section 2
Sub Section2Code(Target As Range)
Range("A50:A130").EntireRow.Hidden = True
If Range("e27").Value = "" Then
MsgBox ("You need to enter a valuebefore you can proceed")
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Else
If Range("E17").Value = "" Then
MsgBox ("You need to enter a value before you can proceed")
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Else
If Target.Value = "Yes" Then
Range("A50:A60").EntireRow.Hidden = False
End If
End If
End If
End Sub











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks