0

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



2
  • 1
    What's with the extra End Sub? Commented Jun 18, 2020 at 14:36
  • 2
    you have two End Sub in there. Commented Jun 18, 2020 at 14:36

1 Answer 1

1

Just remove the first

End Sub

( the line before the End If)

EDIT#1:

also replace:

$q$2

with:

$Q$2
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for the reply. doing this doesnt autorun the code when the value of Q2 cell changes
@saurabh See my EDIT#1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.