user2803302
user2803302

Reputation: 11

VBA Table Refreshing

I'm creating a worksheet in Excel that is connected to an online database. I made a function that checks if new information has been posted and updates the worksheet accordingly. If there is a new release, I update all the column headings to make room for it using a loop.

My problem is that the function takes forever to run since the table refreshes itself each time I change the column headings.

I'm wondering is there is a way to pause the refresh so the table only refreshes itself once at the end of the vba script.

Thanks. I appreciate your help.

Upvotes: 1

Views: 78

Answers (1)

Gareth
Gareth

Reputation: 5243

To stop formulas from refreshing whilst the code executes, you can use Application.Calculation like so:

Public Sub SomeProcedure()

Application.Calculation = xlCalculationManual

'Code goes here

Application.Calculation = xlCalculationAutomatic

End Sub

This will stop the formulas refreshing until the code in the middle has executed.

Upvotes: 2

Related Questions