Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problems with the Find & Select | Excel Discussion (Misc queries) | |||
Problems with the Right & Find functions | Excel Worksheet Functions | |||
Problems with Find & Replace | Excel Discussion (Misc queries) | |||
Problems with Find in VBA/Excel | Excel Worksheet Functions | |||
Problems, doing a find in another sheet. | Excel Programming |