saurabh
saurabh

Reputation: 3

excel vba code error Block if without end if

I get the subject error with this code. pls help. this code is for hiding n un-hiding a set of rows which are below a certain criteria

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$q$2" Then
    BeginRow = 8
    EndRow = 460
    ChkCol = 13

    For RowCnt = BeginRow To EndRow
        If Cells(RowCnt, ChkCol).Value < Cells(2, 19) Then
            Cells(RowCnt, ChkCol).EntireRow.Hidden = True
        Else
            Cells(RowCnt, ChkCol).EntireRow.Hidden = False
        End If
    Next RowCnt
End Sub
End If
End Sub



Upvotes: 0

Views: 99

Answers (1)

Gary&#39;s Student
Gary&#39;s Student

Reputation: 96753

Just remove the first

End Sub

( the line before the End If)

EDIT#1:

also replace:

$q$2

with:

$Q$2

Upvotes: 1

Related Questions