Problems using Find
There a couple of places that this might have died. When you stpe through the
code (F8 key) which line is the offending line. It could be that the Excel
file does not exist or the sheet does not exist or...
HTH
"James W." wrote:
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,
|