View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Find a value in a worksheet

you need to do an assignment

Dim whatever as Range
Set whatever = Cells.Find(..............)
--
Gary''s Student - gsnu201001


"S Shipley" wrote:

When I run the following code I get an error on the Cells.Find line of code:

Open strFile1 For Input As #1
Open strFile2 For Output As #2
Workbooks.Open FileName:=strFile3

Do While Not EOF(1)
Line Input #1, MyRecord
MyFields = Split(MyRecord, ",")
For FieldPointer = LBound(MyFields) To UBound(MyFields)
strVar1 = MyFields(0): strVar2 = MyFields(1): strVar3 =
MyFields(2)

Range("D1").Activate
Cells.Find(What:=strVar2, After:=ActiveCell, LookIn:=xlValues,
LookAt _
:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase _
:=False, SearchFormat:=False).Activate
' Process data
Next
Loop

The error message says "Object variable or With block variable not set"
This code was working so not quite sure why it quit working.

I'm running the code in VB 6.0

Thanks,Sam