Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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,

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with the Find & Select yaro137 Excel Discussion (Misc queries) 1 January 22nd 09 01:00 PM
Problems with the Right & Find functions beginner here Excel Worksheet Functions 14 July 16th 07 11:20 PM
Problems with Find & Replace Gazzr Excel Discussion (Misc queries) 3 April 7th 06 05:41 AM
Problems with Find in VBA/Excel Roy Kirkland Excel Worksheet Functions 0 November 22nd 04 02:58 AM
Problems, doing a find in another sheet. Jan Kronsell[_3_] Excel Programming 3 October 27th 04 02:58 PM


All times are GMT +1. The time now is 05:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"