Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Error 380 trying to set Control Source
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular sharky12345's Avatar
    Join Date
    Aug 2010
    Posts
    3,239
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Error 380 trying to set Control Source

    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?
    There isn't a day go by without me learning something new about VBA!

  2. #2
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,986
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Error 380 trying to set Control Source

    Are you certain those are valid sheet names in the workbook with the control?

  3. #3
    Board Regular sharky12345's Avatar
    Join Date
    Aug 2010
    Posts
    3,239
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error 380 trying to set Control Source

    Yes - double checked that.
    There isn't a day go by without me learning something new about VBA!

  4. #4
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,986
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Error 380 trying to set Control Source

    Where is the textbox?

  5. #5
    Board Regular sharky12345's Avatar
    Join Date
    Aug 2010
    Posts
    3,239
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error 380 trying to set Control Source

    On a userform
    There isn't a day go by without me learning something new about VBA!

  6. #6
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,986
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Error 380 trying to set Control Source

    Do you get the same error with this:
    Code:
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("TabletResults")
    TextBox1.ControlSource = "'" & ws.Name & "'!B10"

  7. #7
    Board Regular sharky12345's Avatar
    Join Date
    Aug 2010
    Posts
    3,239
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error 380 trying to set Control Source

    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 by sharky12345; Apr 25th, 2016 at 11:06 AM.
    There isn't a day go by without me learning something new about VBA!

  8. #8
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,986
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Error 380 trying to set Control Source

    So when I said "Are you certain those are valid sheet names"...

  9. #9
    Board Regular sharky12345's Avatar
    Join Date
    Aug 2010
    Posts
    3,239
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error 380 trying to set Control Source

    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 by sharky12345; Apr 25th, 2016 at 11:45 AM.
    There isn't a day go by without me learning something new about VBA!

  10. #10
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,188
    Post Thanks / Like
    Mentioned
    62 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Error 380 trying to set Control Source

    If there are spaces in a sheet name you need to enclose it in '.
    If posting code please use code tags.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •