Displaying Worksheets in a Slideshow Fashion

Written by Allen Wyatt (last updated May 22, 2021)
This tip applies to Excel


1

Barbara is trying to find a way to display several worksheets, one after another, almost like a slideshow. All the worksheets are in the same workbook. She wants each worksheet to show for 5-10 seconds, then automatically jump to the next worksheet and show for 5-10 seconds, and so on. The concept is to keep everything live and people can view it on a monitor by just waiting for their worksheet to pop up.

This is relatively easy to do by relying on the .Wait method to pause your macro for a specified length of time. All you need to do is to step through the display of each worksheet with the pause between each display. The following macro will accomplish the task:

Sub SlideShow1()
    Dim dDelay As Date
    Dim w As Worksheet

    dDelay = TimeValue("00:00:08")

    For Each w In Worksheets
        DoEvents
        w.Activate
        Application.Wait (Now() + dDelay)
        DoEvents
    Next w
End Sub

The macro pauses for eight seconds, but you can change the length of time in the line that assigns a value to the dDelay variable. Note that the macro also uses the DoEvents function a couple of times in the display loop so that you can, if desired, press Ctrl+C to break out of the macro.

Note that the macro only steps through the Worksheets collection once. If you want to do so multiple times, you can either restart the macro once it is done, or you can modify the macro so that the For Each loop is contained within an outer For Next loop that controls the number of times through the Worksheets collection.

Note, as well, that the macro simply steps through the worksheets, but this may not give you the result you want. The Worksheets collection is not guaranteed to be in any particular order, so what you see may be worksheets that aren't in your desired order. A better approach may be to specify the exact order you want. The following variation of the macro accomplishes this:

Sub SlideShow2()
    Dim dDelay As Date
    Dim J As Integer
    Dim iCnt As Integer
    Dim sNames(19) As String

    sNames(1) = "Sheet3"
    sNames(2) = "Sheet1"
    sNames(3) = "Sheet2"
    sNames(4) = "Sheet1"
    sNames(5) = "Sheet5"
    iCnt = 5

    dDelay = TimeValue("00:00:08")

    For J = 1 To iCnt
        DoEvents
        Worksheets(sNames(J)).Activate
        Application.Wait (Now() + dDelay)
        DoEvents
    Next J
End Sub

The macro takes a bit more to set up, as you need to assign worksheet names into the sNames array. (These need to be spelled exactly, as they appear on the worksheet tabs.) Place them in the order desired, and you can even repeat a worksheet multiple times, as is done with . The iCnt variable then should be set to the number of worksheet names in the sNames array. The display loop then steps through the array and displays each specified worksheet, in turn.

If you want to get fancier with your slideshow, you might want to consider taking screen shots of your worksheets and then putting those screen shots into a Powerpoint presentation.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13862) applies to Microsoft Excel .

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Forcing Printouts to Black and White

If you want to force Word to print some of its colors in black and white, you may be out of luck. One bright spot, as ...

Discover More

Shortening Word's Font List

When you format the text in a document, you can use any of the fonts that Word makes available to you. If that font list ...

Discover More

Controlling How Body Text is Displayed

When working in Outline view, you can control how Word displays the body text under each heading. You can specify that ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Friendly and Informative Error Handling

When creating macros, it is helpful to know what is going on within the macro itself in case an error crops up. Here's ...

Discover More

Running a Procedure when a Workbook is Opened

Ever want to have Excel run a procedure whenever you open a workbook? It's not as difficult as you might think. Here's how.

Discover More

Excel Crashes when Running Macros

It can be frustrating when macros don't run as you expect. When it occurs, however, tracking down the cause can be even ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 5 - 5?

2021-05-22 07:49:44

Michael (Micky) Avidan

If one wants the Show to non-stop circulate until hitting Ctrl+Break:

Sub SlideShow1()
Dim dDelay As Date
Dim w As Worksheet
dDelay = TimeValue("00:00:08")
For Each w In Worksheets
DoEvents
w.Activate
Application.Wait (Now() + dDelay)
Next
Run "SlideShow1" ' < < <
End Sub

------------------
Micky Avidan


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.