View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
wadeni wadeni is offline
external usenet poster
 
Posts: 1
Default Problem using "Find" WorksheetFunction in Excel VBA

I'm trying to use the "Find" WorksheetFunction to hide all rows that d
not contain a predefined string (Initials) in column C. I keep gettin
the error:

Run-time error '1004':
Unable to get the Find property of the WorksheetFunction class

In Excel, this function returns #VALUE if the string you are lookin
for is not found, but in VBA I am encountering this error whether th
string is (or should be) found or not.

Dim FindVal as Double
Dim Initials as String
Dim N as Variant
Dim CellRef as Variant

For N = 5 to 300

CellRef = "C" & N
Initials = "GW" 'this is passed from another procedure

On Error Resume Next
FindVal = WorksheetFunction.Find(Initials, CellRef)
If Err.Number = 1004 Then
Worksheets("name").Rows(N).Hidden = True
End if

Next

--
Message posted from http://www.ExcelForum.com