Solved

Excel 2013 shape height change display mystery

Posted on 2014-12-13
1
179 Views
Last Modified: 2014-12-13
I'm trying to understand this. I have a shape that I want to animate its height growing. Like this

Sub ShapeHeightAnimation()

    Dim Total As Double

    ActiveSheet.Shapes("Rectangle 1").Height = 0
        
    For i = 1 To 100
        ActiveSheet.Shapes("Rectangle 1").Height = i
        
        'slow down
        For iRow = 1 To 8000
            Total = Total + Sheet2.Cells(iRow, 1).Value / 1000
        Next iRow        
    Next i

End Sub

Open in new window


BUT, the shape does not change height during the For-Next loop, but it updates the display only when the code has finished running. (Note the 'slow down')
I tried Application.ScreenUpdating = True but had no effect.

My simple animation test should work, right?
0
Comment
Question by:hindersaliva
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40498175
You have to give up some processing time to allow Windows to redraw the shape.You can do that with  the DoEvents statement.
Sub ShapeHeightAnimation()
    Dim i As Integer
    Dim iRow As Integer
    Dim Total As Double

    ActiveSheet.Shapes("Rectangle 1").Height = 0
        
    For i = 1 To 100
        ActiveSheet.Shapes("Rectangle 1").Height = i
        DoEvents
        'slow down
        For iRow = 1 To 8000
            Total = Total + Sheet2.Cells(iRow, 1).Value / 1000
        Next iRow
    Next i

End Sub

Open in new window

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now