PDA

View Full Version : Novice syntax question...if then statements...error 1004



sampson
04-09-2017, 10:44 PM
I have a spreadsheet with four columns. The range is H11:L62.


The fourth column in the range is titled "Difficulty".


The only values in the Difficulty column are "Easy", Moderate", and "Hard".


I have added Filters to all of the column titles.


I am attempting to control what rows are seen by adding some OptionButtons to the side. (I know this seems like an extra step but please ignore that)


I am using the following syntax but getting error 1004 on row 4. Any idea as to why?


(My goal here is to only show the rows that have "Easy" in the Difficulty column if the optEasy OptionButton has been selected. Likewise with Moderate and Hard)



Private Sub optEasy_Click()
'This is a filter to show only easy hikes and hide all non-easy hikes
If optEasy = True Then
ActiveSheet.Range("H11:L62").AutoFilter field:=4, criterial:="Easy", VisibleDropDown:=False
Else
ActiveSheet.Range("H11:L62").AutoFilter field:=4
End If
End Sub




18899

mancubus
04-10-2017, 01:27 AM
Tell Excel that optEasy is an option button and its value is True (or false)...