Loop function unexpectedly ended at line 20.

Rpaikh

New Member
Joined
Jul 28, 2019
Messages
27
Hello,


I have a trouble with my loop function where it show "Error occured while retrieving data" and the code is always ended at line 20. Can somebody help me if there's any thing wrong with my code so far ?



Code:
Dim r As Range, rall As Range
With ActiveSheet
    Set rall = .Range("a2", .Range("a" & .Rows.Count).End(xlUp))
End With
For Each r In rall
    Set rdate = r


'Script name 1'


objSess.findById("wnd[0]").maximize
objSess.findById("wnd[0]/tbar[0]/okcd").Text = [COLOR=#ff0000]rdate[/COLOR]
objSess.findById("wnd[0]").sendVKey 0
objSess.findById("wnd[0]/tbar[1]/btn[17]").press


Next r
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi Rpaikh,
I assume the values in the range are all values (no formulas)? Your code looks fine to me, I don't see anything weird (although you cut out quite a bit where you surf to the website etc.). And does your code end the first time it passes at the = rdate line (I assume that's line 20)? It could be that rdate.Value is needed to make it work.
Koen
 
Upvote 0
7436743 - doesn't show as a date in a date formatted cell if that's what it is supposed to be.
One too many digits or too far into the future.
 
Last edited:
Upvote 0
Hi Rpaikh,
I assume the values in the range are all values (no formulas)? Your code looks fine to me, I don't see anything weird (although you cut out quite a bit where you surf to the website etc.). And does your code end the first time it passes at the = rdate line (I assume that's line 20)? It could be that rdate.Value is needed to make it work.
Koen


Hello Rijnsent,

You're right there's something wrong with the rdate value in line 20. After I changed raw data in line 20 to be something else, it work as expected.

May I ask you if I want to add more raw data like rdate2 under column "B" and rdate3 under column "C" how the code would look like ?



Code:
Dim r As Range, rall As Range
With ActiveSheet
    Set rall = .Range("a2", .Range("a" & .Rows.Count).End(xlUp))
End With
For Each r In rall
    Set rdate = r


'Script name 1'


objSess.findById("wnd[0]").maximize
objSess.findById("wnd[0]/tbar[0]/okcd").Text = [COLOR=#ff0000]rdate
[/COLOR]objSess.findById("wnd[0]/tbar[1]/okcd").Text = [COLOR=#ff0000][FONT=Verdana]rdate2
[/FONT][/COLOR]objSess.findById("wnd[0]/tbar[2]/okcd").Text = [COLOR=#ff0000][FONT=Verdana]rdate3[/FONT][/COLOR]
objSess.findById("wnd[0]").sendVKey 0
objSess.findById("wnd[0]/tbar[1]/btn[17]").press


Next r

5hC6
 
Upvote 0
Hi Rpaikh,
if you want those, you could do it like this:
Koen
Code:
Dim r As Range, rall As Range

    Set rall = ActiveSheet.Range("a2", .Range("a" & .Rows.Count).End(xlUp))
'This is a range of one column
For Each r In rall
    rdate = r.value
    rdate2 = r.offset(0,1).value 'column next to it
    rdate3 = r.offset(0,2).value 'column C

'Script name 1'

objSess.findById("wnd[0]").maximize
objSess.findById("wnd[0]/tbar[0]/okcd").Text = rdate
objSess.findById("wnd[0]/tbar[1]/okcd").Text = rdate2
objSess.findById("wnd[0]/tbar[2]/okcd").Text = rdate3
objSess.findById("wnd[0]").sendVKey 0
objSess.findById("wnd[0]/tbar[1]/btn[17]").press


Next r
 
Upvote 0
This perfectly work! Thank you once again !


Hi Rpaikh,
if you want those, you could do it like this:
Koen
Code:
Dim r As Range, rall As Range

    Set rall = ActiveSheet.Range("a2", .Range("a" & .Rows.Count).End(xlUp))
'This is a range of one column
For Each r In rall
    rdate = r.value
    rdate2 = r.offset(0,1).value 'column next to it
    rdate3 = r.offset(0,2).value 'column C

'Script name 1'

objSess.findById("wnd[0]").maximize
objSess.findById("wnd[0]/tbar[0]/okcd").Text = rdate
objSess.findById("wnd[0]/tbar[1]/okcd").Text = rdate2
objSess.findById("wnd[0]/tbar[2]/okcd").Text = rdate3
objSess.findById("wnd[0]").sendVKey 0
objSess.findById("wnd[0]/tbar[1]/btn[17]").press


Next r
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,541
Latest member
iparraguirre89

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