sparky2205
Well-known Member
- Joined
- Feb 6, 2013
- Messages
- 507
- Office Version
- 365
- 2016
- Platform
- Windows
Hi folks,
in the following code I'm getting the above error.
It errors at:
i.e. the first IF statement.
"category" is populated with a value that exists in column I
It worked fine yesterday, but has decided not to work today.
Any thoughts?
in the following code I'm getting the above error.
VBA Code:
Sub Filter_By_Category()
Dim lastrow As Long
Dim count As Long
Dim count1 As Long
Dim lvalue As Long
Dim category As String
Dim srange As Long
srange = 9
lastrow = Cells(Rows.count, 3).End(xlUp).Row
' Hide all vendors
Rows("9:" & lastrow).EntireRow.Hidden = True
category = Application.InputBox("By which Category do you wish to filter?", Type:=2)
count = WorksheetFunction.CountIf(Range("I9:I" & lastrow), category)
For i = 1 To count
If i = 1 Then
lvalue = Range("I" & srange & ":I" & lastrow).Find(category).Row + 8
Else
lvalue = Range("I" & srange & ":I" & lastrow).Find(category).Row
End If
' lvalue = Application.Match(category, Sheets("Revised").Range("I"& srange & ":I" & lastrow), 0) + 8
Rows(lvalue & ":" & (lvalue + 3)).Hidden = False
srange = lvalue + 3
Next i
'lvalue = WorksheetFunction.XLookup(category, Range("I9:I" & lastrow), Range("I9:I" & lastrow), "Selected category not found")
End Sub
It errors at:
VBA Code:
lvalue = Range("I" & srange & ":I" & lastrow).Find(category).Row + 8
"category" is populated with a value that exists in column I
It worked fine yesterday, but has decided not to work today.
Any thoughts?