Error 380 trying to set Control Source

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to use VBA to set the Control Source to a Textbox by using this;

Code:
TextBox1.ControlSource = "TabletResults!B10"

but I get an error 380.....I have also tried this with the same result;

Code:
TextBox1.ControlSource = "Sheet3!B10"

Can anyone point me to why it fails?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Are you certain those are valid sheet names in the workbook with the control?
 
Upvote 0
Where is the textbox?
 
Upvote 0
Do you get the same error with this:
Code:
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("TabletResults")
TextBox1.ControlSource = "'" & ws.Name & "'!B10"
 
Upvote 0
With that I got a run time error 9, subscript out of range.....

but changing it to this worked;

Code:
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Tablet Results")
TextBox1.ControlSource = "'" & ws.Name & "'!B10"
 
Last edited:
Upvote 0
So when I said "Are you certain those are valid sheet names"... ;)
 
Upvote 0
This;

Code:
TextBox1.ControlSource = "TabletResults!B10"

didn't work when I tried this;

Code:
TextBox1.ControlSource = "Tablet Results!B10"

that's why I said the sheet names were correct because I tried it with spaces and it still didn't work.
 
Last edited:
Upvote 0
If there are spaces in a sheet name you need to enclose it in '.
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,222
Members
448,877
Latest member
gb24

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