Do Loop running slow

pincivma

Board Regular
Joined
Dec 12, 2004
Messages
206
Hi there

I did a very simple Do Loop macro. Below is the code:

Sub reinstatesformulas()

Application.ScreenUpdating = False
Range("AA106").Select
Do
ActiveCell.Select
If ActiveCell = "No Entry" Then
ActiveCell.Offset(0, -23).Select
ActiveCell.FormulaR1C1 = "=IF(R2C1=TRUE,RC[6],0)"
ActiveCell.Offset(0, 23).Select
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell = "."
End Sub

This code takes 1 and 1/2 minutes to run since it has to go through 14,000 rows until it hits the end. Is there a better macro that can make this code run faster?
 
My original code had a Do Loop and I had to tell Excel when to stop. So I decided to tell Excel to stop when it encountered a period. What if I deleted the line "If MyData(r, 1) = "." Then Exit Sub" I wonder if that would help fix the problem. I should give that a try.
 
Upvote 0

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.
My original code had a Do Loop and I had to tell Excel when to stop. So I decided to tell Excel to stop when it encountered a period. What if I deleted the line "If MyData(r, 1) = "." Then Exit Sub" I wonder if that would help fix the problem. I should give that a try.

Hey it worked.
 
Upvote 0

Forum statistics

Threads
1,223,923
Messages
6,175,398
Members
452,640
Latest member
steveridge

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