Adding pauses to a macro

Sweedler

Board Regular
Joined
Nov 13, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hello

Sub New_country_Click()

Dim i As String
Dim w As Long
Dim v As Long

Range("P5").Formula = "=XLOOKUP(1,I:I,B:B,"""",0)"
w = 50000

Application.CalculateFullRebuild
For v = 1 To w
Next v
Application.CalculateFullRebuild
For v = 1 To w
Next v
Application.CalculateFullRebuild
For v = 1 To w
Next v
Application.CalculateFullRebuild
For v = 1 To w
Next v
Application.CalculateFullRebuild

i = Range("P5")
Range("P5") = i

End Sub


I am currently using the following. Each time "CALCULATEFULLREBUILD" is the "xlookup" formula present a name in cell P5. I want this process to cycle 5-10 times, but I need there to be a pause so that the name in P5 can be registered. I basically want it to look like it is cycling through a selection of names before it settles with the final one. That is when the value is copied in so that it does not change anymore.

Please help
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Have a look at Application.Wait
Hello

I tried that application, but as I was unable to make the "time delay" shorter than 1 second it was not good enough. I need it to cycle quicker.
 
Upvote 0
Thank you all for your input:

Here is how I solved my issue in the end.
Sub New_country_Click()

Dim i As String
Dim f As Integer

For f = 3500 To 1 Step -1

Range("P5").Formula = "=XLOOKUP(1,I:I,B:B,"""",0)"
Next f

i = Range("P5")
Range("P5") = i

End Sub


The Italic loop in the middle does what I wanted it to do. In cell P5 I am showing the value from column B, that in column I has the value 1. Column I gets its values from a series of random number generators. So what this Macro now does is cycle through some names that is quickly shows in cell P5 before settling for the 1 country.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,151
Messages
6,123,316
Members
449,094
Latest member
Chestertim

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