Runtime error after update

kyndsi

New Member
Joined
Feb 16, 2018
Messages
16
I have a macro in an Excel document that scrapes data from the Attachmate / Micro Focus Reflection application. It has been running fine for over a year, but we have now been updated company wide to Office 2016 and Reflection 16. There is now one specific routine that fails with a run-time error.

Code:
displayRow = GetNextOffset(displayRow + 1)
       If hrn.getString(displayRow, 4, 1) = " " Or displayRow = 0 Then
            hrn.MoveTo 1, 5
            Exit Sub
       End If


This code is part of a Sub that pulls data row by row from a particular screen, and this is the section of the sub that looks for a blank row which indicates the end of the data, and exits this sub. The GetNextOffset function does a data validation on each row to determine if the row will be used or skipped.

When I run the macro as is, everything works as expected until it reaches the blank row, and the end of the data on the screen. Then it throws the following error:

Run-time error ‘-2146233086 (80131502)’:Specified argument was out of the range of valid values.Parameter name: row

If I change the displayRow variable in each getString query to the actual row number for each row of data, the macro runs flawlessly.

Any thoughts as to what may be causing this error?
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
perhaps this
Code:
If hrn.getString(displayRow, 4, 1) = [COLOR=#ff0000]" "[/COLOR] Or displayRow = 0 Then
should be
Code:
If hrn.getString(displayRow, 4, 1) = [COLOR=#ff0000]"" [/COLOR]Or displayRow = 0 Then

You could test values with Debug.Print immediately failing line and see results in immediate window - the last 3 values may tell you something useful

Code:
Debug.Print hrn.getString(displayRow, 4, 1)
Debug.Print Len(hrn.getString(displayRow, 4, 1))
Debug.Print displayRow
 
Last edited:
Upvote 0
Oops :oops:
above should read "... immediately above failing line ..."
 
Upvote 0
could the data site also have been updated?
 
Upvote 0
AS it turns out, the culprit was the function (GetNextOffset). It also has a blank row check for end of data, and the exit routine did not have a declaration for the value of the variable, so it was returning nothing on the last query, which was in turn messing up the row value in this sub.

Thanks again for your time and thoughts on this.
 
Upvote 0

Forum statistics

Threads
1,224,526
Messages
6,179,322
Members
452,906
Latest member
Belthazar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top