ActiveX Text Box not updating

filido

New Member
Joined
Jun 7, 2019
Messages
21
Hi, I have grouped an ActiveX text box with Excel's box and whiskers chart. I want the text box to update as the data table is filtered. First, I used the Linked Cell -function but it doesn't update the text box when I run my macro. It sorta "reacts" slowly, in a sense that the value of text box SHOULD be 'Chart 1', 'Chart 2', 'Chart 3' etc. But now it goes 'Chart 1', 'Chart 1', Chart 2'...

Then I removed the Linked Cell and added this to my code:

wsChart.OLEObjects("TextBox1").Object.Value = "Chart name"

I have to add this line after every filtering. However, this too only works when I run my macro step by step with F8. When I run my macro as a whole, the text box only applies the first filter value and it does not update as the data table is filtered.

The box and whiskers chart is really annoying because I also have a scatter chart and I have no problem with it but with box&whiskers there seems to always be some issue with it!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
I have not tested this with a "box and whiskers" chart (whatever one of those may be :confused:) but here is something to try
- link the textbox to a cell (in my example below it is B2)
- in VBA write value to a cell whenever chart name changes (in my test Chart 1 , Chart 2...Chart 50 )
- on next line after name change insert this line
Code:
  Application.Calculate



In my test

- B2 updates regardles of Application.Calculate but the TextBox behaves differently
- without Application.Calculate the textbox updates ONCE (at the end)
- with Application.Calculate the textbox updates every time x changes

Code:
Sub Test()
    Dim shp As Shape, aCount As Long, x As Long, y As Long
    Set shp = Me.Shapes("TextBox 1")

    For x = 1 To 50
        For y = 1 To 1000
            Range("B2") = "Chart " & x
        Next y
        Application.Calculate
    Next
MsgBox "done"
End Sub
 
Last edited:
Upvote 0
oops :oops:
- above test worked with a standard textbox but when I tested with active-x textbox it does not update :confused:

Would a standard textbox do everything you require ?
- if so give suggestion in post#2 a try
 
Upvote 0
Hi, I will try to add this Application.Calculate but now that I changed my textbox to standard textbox, I don't know how to assign a value to it...
Sheets("Sales").TextBox1.Value = "___" Doesn't work.
 
Upvote 0
The shape is usually auto-created where it name has a space between TextBox and its number

This works for me
Code:
Sheets("Sales").Shapes("TextBox 1").Characters.Text = "???"
Application.Calculate

Or
- assign a cell value to the shape by clicking on shape to select it and then in formula bar ...
=B2

AND update the cell during the macro
Code:
Range("B2") = "???"
Application.Calculate
 
Last edited:
Upvote 0
Hi! I figured it out. I added a standard textbox and then added to my code:

Sheets("Sales").Shapes("TextBox 1").TextEffect.Text = "???"
Application.Calculate

Now the textbox updates at the same time with the boxplot. Thank you for telling me that the shape is usually auto-created when there's a space between TextBox and its number. A very small detail but important to me that helped me a lot.
 
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

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