View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
James W.[_2_] James W.[_2_] is offline
external usenet poster
 
Posts: 31
Default Problems using Find

I can't get this to work. I receive the error message "Object variable or
with variable not set". Could someone please help. Here is the code:


Private Sub CommandButton1_Click()

Dim OrderToFind
Dim MyValue

OrderToFind = ActiveSheet.Range("E17").Value
MyValue = ActiveSheet.Range("F15").Value


' Check if workbook is already opened.
'On Error Resume Next
Set x = Workbooks("OrderTracking.xls")
If Err = 0 Then
Windows("OrderTracking.xls").Activate
Sheets("To Finish").Activate
Else
Workbooks.Open Filename:="\\Fs1\Material\Scheduling\OrderTracking .xls"
Sheets("To Finish").Activate
End If

Sheets("To Finish").Range("C1").Select

'On Error GoTo Errorhandler
'Find the order numbers comment line
Cells.Find(OrderToFind & " Count").Select

'Offset to the correct column and insert data
ActiveCell.Offset(0, 32).Value = MyValue

Exit Sub
'Errorhandler:
MsgBox "Order number " & OrderToFind & " was not found."

End Sub


Much Thanks,