Looping in a loop exit issue

Thinkn

New Member
Joined
Oct 10, 2018
Messages
4
I am working on a loop which functions as intended exceptfor the conditional expression and which keeps looping.

Ibelieve it maybe my method of assigning the conditional expressions “Do While TAIPlan = TAIPlan2”..” IfTAIPlan <> TAIPlan2 Then Exit Do”.


Basically I’m trying to compare one reference on say page 1 to same refpage two. If they’re the same then take a screen screen shot, otherwise exitloop.

At the moment this doesn’t recognize when they’re differentand never exits the loop.

Any help is appreciated!




Dim TAIReturn1 As Object

Dim TAIReturn2 As Object
Dim wsSheet As Worksheet
Dim TAIPlan As Object
Dim TAIPlan2 As Object



Set TAIReturn1 =MyScreen.Select(1, 1, 24, 80)
Application.GotoReference:="NewSP" ‘<-specified target cell

ActiveCell.FormulaR1C1 = TAIReturn1



'''Loop here to account forthe multiple sequence screens per search plan



Set TAIPlan =MyScreen.Select(2, 26, 2, 40) ‘<-Page one Ref
MyScreen.SendKeys ("<Enter>")

Set TAIPlan2 =MyScreen.Select(2, 26, 2, 40) ‘<- Page two Ref

Do While TAIPlan= TAIPlan2




Set TAIReturn2 =MyScreen.Select(8, 1, 24, 80)
Sheets("Stage").Select
Application.Wait Now + TimeValue("00:00:02")

Application.SendKeys ("{TAB}")
DoEvents


Application.Wait Now + TimeValue("00:00:02")
ActiveCell.FormulaR1C1 = TAIReturn2


MyScreen.SendKeys ("<Enter>")
SetTAIPlan2 = MyScreen.Select(2, 26, 2, 40) ‘<- New Page two Ref




IfTAIPlan <> TAIPlan2 Then Exit Do


Loop

 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I think it is because they are never different.

Code:
Set TAIPlan =   MyScreen.Select(2, 26, 2, 40)        '<-Page one Ref
Set TAIPlan2 = MyScreen.Select(2, 26, 2, 40)       '<- Page two Ref
Set TAIPlan2 = MyScreen.Select(2, 26, 2, 40)        '<- New Page two Ref
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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