The Range object from which i am finding exists, but you get an "Index is not in scope" error.
Please tell me the cause.
public sub sub1 (filePath as string)
On Error GoTo ErrProc
'Checked if the book and sheet below exist
Dim wb As Workbook
Set wb = Workbooks.Open (filePath, False, True)
Dim st As Worksheet
Set st = wb.Worksheets ("xx")
Dim rng As Range
Set rng = st.Cells.Find ("xxx",, xlValue, xlWhole)
↑ Here, "Index is not in the valid range" error occurs
'The following processing is omitted.
I searched a lot, but the "index is not in the valid range" error is because there is no object
Although it is written, it exists even if you look at st on the watch.
Answer # 1
Try xlValues instead of xlValue
Set rng = st.Cells.Find ("xxx",, xlValues, xlWhole)
Range.Find method (Excel)
LookIn Optional Variant You can use XlFindLookIn constants: either xlFormulas, xlValues, xlComments or xlCommentsThreaded.
Answer # 2
Answer # 3
The question code has an extra comma, so remove it.
Set rng = st.Cells.Find ("xxx", xlValue, xlWhole)
- vba error handling index is not in the valid range
- excel vba that does not overwrite and save only when an error occurs
- excel vba causes automation error when duplicating sheet
- vba - about index error
- about excel vba out of memory error
- macros created in excel on vba mac cannot be executed normally on windows
- how to transfer between conditional excel files using vba macros
- (vba) how to transfer excel data to ie
- python - list index out of range error occurs for index 0
- excel vba add-in
- i want to post from excel vba using wordpress rest api
- vba - i want to get a selenium string in excel
- excel vba displays "&h8000ffff (-2147418113) this is a fatal error"
- vba - i changed it to excel oracle 122c ora-01017: invalid username/password logon refused
- c # - what to do about the error message "index is out of array bounds"
- about loop using vba excel left
- vba - win32 api run-time error setthreaddesktop
- i want to make the inside of the excel vba text box transparent
- i get an error when getting a url using ie with vba
- excel : How to insert a note with the text from the neighboring cell
- vba - i want to be able to use wildcards for aggregation in excel
- i want random numbers with no duplicates in excel vba
- (vba) when posting excel data to ie, a row different from the expected row is posted
- vba - i don't know where the syntax error is in the advanced filter in the excel macro
- please tell me how to use the excel vba split function macro well
- how to make macro work properly with the folder path set in the vba cell
- i want to create a pull-down list from the table on another vba sheet
- vba - i want to search for the character string entered in the user form and paste the cell
- image file size increase prevention vba