force refresh of a Text Box (Shape) displaying text

destructa

New Member
Joined
Nov 14, 2011
Messages
3
Hi gang,

I had a frustrating problem with a shape on my worksheet. It is a Text Box Shape (not a userform type) and it is supposed to display text from a specific cell. The cell contains an INDEX formula, so the contents change based on a scrollbar control elsewhere.

My problem was, the Text Box would not always "refresh" its contents when the cell contents changed. It seemed the workbook had to be open for a few minutes before it would respond properly. I watched the cell while using the scrollbar control and it was updating just fine; the problem was definitely between the cell and the Shape. I have read that Shapes have "slow code" in Excel 2007.

I thought of attaching a macro to the scrollbar that would force a refresh of the shape along with performing the scrollbar's normal action. I failed to find any "refresh" or "repaint" methods for Shapes in VBA, so I resorted to using two horizontal flips--just activating something on the Shape seems to be enough to force the refresh, and I don't notice a delay. I named my Shape based on its purpose, to show explanatory notes next to a dynamic chart.

Code:
Sub RefreshEvent()
Dim db As Worksheet
Set db = Sheets("Dashboard")
db.Shapes("PieScrollShowEvent").Flip msoFlipHorizontal
db.Shapes("PieScrollShowEvent").Flip msoFlipHorizontal
End Sub

So this appears to have solved my problem. If someone is having the same problem, this may help. Also, if anyone has a better solution, please share. I may have overthought this a bit.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top