Spin button and Shapes

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,834
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a shape on a worksheet, which when clicked, appears to show a chart moving in real time through all its values, say 1 to 100.

I also have a Spin button, which when clicked, moves the chart one value at a time.

The problem is after clicking the Spin button, if I immediately click the shape, the chart does NOT appear to be moving. When the loop has finished, the chart just show the "final" position.

However, if after clicking the Spin button, I click on any cell on the worksheet, THEN click the shape, the chart moves in real time.

Does anybody know what causes this problem?

Thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Something to try ...

Add this as the last line in the spin button's event macros
If you are using Spin_Down and Spin_Up, then add to both

VBA Code:
Private Sub SpinButton1_Change()
    SpinButton1.TopLeftCell.Activate
End Sub
 
Upvote 0
Something to try ...

Add this as the last line in the spin button's event macros
If you are using Spin_Down and Spin_Up, then add to both

VBA Code:
Private Sub SpinButton1_Change()
    SpinButton1.TopLeftCell.Activate
End Sub

Thanks, that did the trick.

On a similar note, I noticed when I clicked on the shape to move the chart in real time, that only worked if the chart was activated.

Something like this:

Code:
    Dim Ticker As Integer
    
    Ticker = wksData.Cells(19, 16).Value
    
    Do Until Ticker = 100
    
        Ticker = Ticker + 1
        
        Application.EnableEvents = False
        
        Dim Cht As ChartObject
        Set Cht = wksData.ChartObjects("Chart 1")

        Cht.Activate
     
        wksData.Cells(19, 16).Value = Ticker
        
        DoEvents
        
        Application.EnableEvents = True
        
        Call ModGlobal.Sleep(Milliseconds:=500)

    Loop

Do you know if it's possible without activating the chart?
 
Upvote 0
why do you not want to activate the chart?
 
Upvote 0
why do you not want to activate the chart?

Looks ugly.

Seems like a bug that the chart eventually shows the "final position" if it's NOT activated, instead of updating in real time.
 
Upvote 0
It is not a bug
Displayed cells are updated instantly by code but that is not the case for other objects (happens when the code finishes running)

Something to try (untested)
Rich (BB code):
AFTER ...
DoEvents
INSERT THIS LINE ...
Cht.TopLeftCell.Activate
 
Upvote 0
It is not a bug
Displayed cells are updated instantly by code but that is not the case for other objects (happens when the code finishes running)

Something to try (untested)
Rich (BB code):
AFTER ...
DoEvents
INSERT THIS LINE ...
Cht.TopLeftCell.Activate

Thanks, it looks a lot better with your line.

The chart is no longer activated when the code is looping.

What exactly is your code doing? Reading it, I would have thought it's activating the top left cell, so therefore the chart would still look activated (with the eight circles around the edge of it) but actually it's not.
 
Upvote 0
your original code activates the chart inside the loop
the chart is then updated
my line activates a cell (which deactivates the chart)
any cell could have been used (topleftcell is hidden behind the chart)
and then the code loops again

Fortunately user does not see the chart being activated
 
Upvote 0
your original code activates the chart inside the loop
the chart is then updated
my line activates a cell (which deactivates the chart)
and then the code loops again

Fortunately user does not see the chart being activated

Brilliant, thanks a lot.
 
Upvote 0

Forum statistics

Threads
1,215,741
Messages
6,126,588
Members
449,319
Latest member
iaincmac

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