Loop still running?

davidam

Active Member
Joined
May 28, 2010
Messages
497
Office Version
  1. 2021
Platform
  1. Windows
Hello,
I am using variable x to end a loop as follows:
Code:
Dim x As Integer
x = 1
Set portColumn = ThisWorkbook.Worksheets("Web").Range("U69")
Do Until x = 5
Call GoGetData
Call CleanNewData
Call MakeNewFile
Set portColumn = portColumn.Offset(0, 2)
x = x + 1
Loop
This works fine. There are 4 blocks of data to process; the last line of the last Sub is completed properly, after the 4th block of data. Everything stops at the right time except that the module continues to say "running" and I need to press the stop button to get rid of this. Any suggestions? Many thanks.
David
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi

Try -
Code:
Dim x As Integer
x = 1
Set portColumn = ThisWorkbook.Worksheets("Web").Range("U69")
Do 
    Call GoGetData
    Call CleanNewData
    Call MakeNewFile
    Set portColumn = portColumn.Offset(0, 2)
    x = x + 1
Loop Until x = 5

hth
 
Upvote 0
Try Code below

Code:
Sub Test()
Dim x As Integer

For x = 1 to 5
Set portColumn = ThisWorkbook.Worksheets("Web").Range("U69")

Call GoGetData
Call CleanNewData
Call MakeNewFile
Set portColumn = portColumn.Offset(0, 2)
Next X
 
End Sub
 
Upvote 0
I have tried these methods and they do seem to be more reliable. Thank you.
 
Upvote 0
Hi

Pleased to have helped solve your problem.

Thanks for the feedback.

Good luck with your project.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

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