ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range.Find abend on XP/Excel 2003 (https://www.excelbanter.com/excel-programming/350705-range-find-abend-xp-excel-2003-a.html)

PT91745

Range.Find abend on XP/Excel 2003
 
Below code got subscript out of range abend on XP/Excel 2003, but works find
on excel 2000. Does range.Find function not working on Excel 2003? Any
suggestion?


oriReportStartRow = oriRowIndex + oriBlankLine + oriHeaderLine + oriTOTALLine
oriGPStart = oriReportStartRow
objSheet(orisheet).Cells(oriReportStartRow - 1, 1) = "Gross Profit"
objSheet(orisheet).Cells(oriReportStartRow - 1, 1).Font.Bold = True
oriRowIndex = oriReportStartRow

'test find statement
Dim oriSearch As Range
Set oriSearch = objSheet(orisheet).Range("A2:IV100").Find("Gross
Profit", LookIn:=xlValue) ---- Abend subscript out of range???

PT91745

Range.Find abend on XP/Excel 2003
 
I finally figure out what is wrong, on excel 2000 Find function works on
both LookIn:=xlValue or LookIn:=xlValues. But Excel 2003 will abend with
subscript out of range when use LookIn:=xlValue

so the code shall change to :
Set oriSearch = objSheet(orisheet).Range("A2:IV100").Find("Gross
Profit", LookIn:=xlValues

"PT91745" wrote:

Below code got subscript out of range abend on XP/Excel 2003, but works find
on excel 2000. Does range.Find function not working on Excel 2003? Any
suggestion?


oriReportStartRow = oriRowIndex + oriBlankLine + oriHeaderLine + oriTOTALLine
oriGPStart = oriReportStartRow
objSheet(orisheet).Cells(oriReportStartRow - 1, 1) = "Gross Profit"
objSheet(orisheet).Cells(oriReportStartRow - 1, 1).Font.Bold = True
oriRowIndex = oriReportStartRow

'test find statement
Dim oriSearch As Range
Set oriSearch = objSheet(orisheet).Range("A2:IV100").Find("Gross
Profit", LookIn:=xlValue) ---- Abend subscript out of range???


Dave Peterson

Range.Find abend on XP/Excel 2003
 
xlvalue = xlValues?

But xl2003 won't crash when you're looking through values.

I'd still bet that your worksheet didn't exist.

orisheet may not be what you think it is.




PT91745 wrote:

I finally figure out what is wrong, on excel 2000 Find function works on
both LookIn:=xlValue or LookIn:=xlValues. But Excel 2003 will abend with
subscript out of range when use LookIn:=xlValue

so the code shall change to :
Set oriSearch = objSheet(orisheet).Range("A2:IV100").Find("Gross
Profit", LookIn:=xlValues

"PT91745" wrote:

Below code got subscript out of range abend on XP/Excel 2003, but works find
on excel 2000. Does range.Find function not working on Excel 2003? Any
suggestion?


oriReportStartRow = oriRowIndex + oriBlankLine + oriHeaderLine + oriTOTALLine
oriGPStart = oriReportStartRow
objSheet(orisheet).Cells(oriReportStartRow - 1, 1) = "Gross Profit"
objSheet(orisheet).Cells(oriReportStartRow - 1, 1).Font.Bold = True
oriRowIndex = oriReportStartRow

'test find statement
Dim oriSearch As Range
Set oriSearch = objSheet(orisheet).Range("A2:IV100").Find("Gross
Profit", LookIn:=xlValue) ---- Abend subscript out of range???


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com