Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Code that worked perfectly in Excel 97 is giving a run-time error
'1004': Application-defined or object-defined error in Excel 2003. The error occurs on the following line in the code sample below. Set rng = sceWB.Worksheets(ws.Name).Range(strNameAddress) Function SearchOrderNum(OrderNum as String, DateStart as Date, DateEnd as Date, resultsArray() As TimeUDT) As Boolean Dim sceWB As Workbook Dim ws As Worksheet Dim strNameAddress as String Dim rng As Range Dim result As Range Set sceWB = ThisWorkbook For Each ws In sceWB.Worksheets strNameAddress = "" 'set up multiple range for Find method, using named ranges with offsets to Order No. column For n = 1 To sceWB.Names.Count If ws.Name = sceWB.Names(n).RefersToRange.Worksheet.Name Then strNameAddress = strNameAddress & sceWB.Names(n).RefersToRange.Offset(0, -4).Address & "," End If Next strNameAddress = Left(strNameAddress, Len(strNameAddress) - 1) 'strip last comma If strNameAddress < "" Then Set rng = sceWB.Worksheets(ws.Name).Range(strNameAddress) With rng Set result = .Find(OrderNum, LookIn:=xlValues) The inner For loop sets up a string of columns to use in the Find method. For the first worksheet, strNameAddress is a string of 261 characters, ie "$A:$A,$G:$G,$M:$M,$S:$S,$Y:$Y,$AE:$AE ......$GQ:$GQ". I don't know if the error is caused by the length of the string, but does anyone know how to solve this problem? Is there any reason why it should work in Excel 97 but not 2003? Also I am open to suggestions about any other ways to set up a Range object of multiple columns to use in the Find method. Thanks Tony |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error 1004 method range of object '_global failed | Excel Discussion (Misc queries) | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
Runime Error 1004 Method Range of Object Global Failed | Excel Programming | |||
"Run-time error '1004'" Method 'Range' of object '_global' failed. | Excel Programming |