?
Solved

Excel 2013 shape height change display mystery

Posted on 2014-12-13
1
Medium Priority
?
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

752 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