Delay a macro in Excel (2013) after all data has refreshed

Have an Excel report fetching data from SQL using an ODC connection.

The data has some long text fields that vary the cell size, sometimes not all is visible until row height is resized.  My goal is to make sure all data is visible and printed, without the having to remember to autosize the row height.

In my little mind, firing a macro on open will fix by autosizing the rows, but can't get teh timing worked out in a delay that allows for data refresh and then autosize?  Of course if there is a better way, taht'd be good, too...
VirtualKansasAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
I'm assuming you are looking for this..

Sub sze()
DoEvents
Cells.EntireRow.AutoFit

End Sub

Open in new window


Saurabh...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VirtualKansasAuthor Commented:
Maybe?  But does it fire after data is refreshed?
Saurabh Singh TeotiaCommented:
Yes..You can run this code even when the data is getting refreshed..it will wait for the data to get refresh first and then resize your rows...
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

VirtualKansasAuthor Commented:
Apologies for not getting back, sooner.
Looking good, so far; may I ask that you please check my process?
If you agree this is best way to handle the process; I believe we're good and will close with my thanks.

Created macro "AutoSize" using your code and then called the macro in an on open event:
Private Sub Workbook_Open()
    Call AutoSize
End Sub

Does seem to allow the refresh and then AutoSize after refresh.  Look good?
Saurabh Singh TeotiaCommented:
Use this..

Private Sub Workbook_Open()
DoEvents
    Call AutoSize
End Sub

Open in new window

VirtualKansasAuthor Commented:
Thank you. Looks great, so far.  
We're testing an online database, so when more data gets entered, we'll know for sure.  
Appreciate your time & patience...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.