+ Reply to Thread
Results 1 to 9 of 9

Trouble Using Control Source in UserForm

  1. #1
    Registered User
    Join Date
    11-02-2014
    Location
    New York
    MS-Off Ver
    2013
    Posts
    4

    Trouble Using Control Source in UserForm

    Hi All,

    In my userform a user is able to enter "Yes" or "No" into textbox1. I want the value displayed in textbox2 to be determined by the user's entry in textbox1.

    E.g.

    User specifies "Yes"

    Control Source for textbox2 is Cell A1

    If user specifies "No"

    Control Source for textbox2 is A2


    I am trying to use IIf ( expr , truepart , falsepart ), but haven't had luck.

    Any help would be great.

    Edit:

    As a side note, I'm only using a textbox for the "Yes" or "No" part because I wasn't sure how to use a listbox.
    Last edited by JPascal; 11-02-2014 at 03:43 PM.

  2. #2
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Trouble Using Control Source in UserForm

    In the : Private Sub TextBox1_Change()

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Trouble Using Control Source in UserForm

    Or with ListBox and TextBox:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Trouble Using Control Source in UserForm

    Double posted.
    Did my solution not work for you?
    http://www.excelforum.com/excel-prog...-userform.html

    As far as I know, a user form's text box doesn't have a ControlSource property.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Trouble Using Control Source in UserForm

    Think ControlSource is the wrong choice of wording...

    I interpreted it as if Yes then A1 otherwise A2.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Trouble Using Control Source in UserForm

    Mike

    A userform textbox does have a ControlSource property.
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    11-02-2014
    Location
    New York
    MS-Off Ver
    2013
    Posts
    4

    Re: Trouble Using Control Source in UserForm

    I'm still having trouble.

    Should I not be entering this code direction into the Control Source?

    I tried Mike's suggestion and JRidge's.

    Would this be the correct code if using a checkbox?

    TextBox2.Value = IIf(CheckBox1.Value = TRUE, Range("A1").Value, Range("A2").Value)

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Trouble Using Control Source in UserForm

    Mac doesn't support the Control Source property.
    If you are using a CheckBox, its value is a boolean, there is no need to test if it =True.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-02-2014
    Location
    New York
    MS-Off Ver
    2013
    Posts
    4

    Re: Trouble Using Control Source in UserForm

    Perfect. Got it figured out. Thank you all.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 01-18-2018, 01:49 PM
  2. Checkbox that dictates control source in userform.
    By JPascal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2014, 05:10 PM
  3. [SOLVED] UserForm - Could not set the Control source property?
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-09-2013, 10:46 AM
  4. Userform Number Format with Control Source
    By okelly in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-11-2012, 07:42 PM
  5. Control Source Updates in Userform
    By incjourn in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-13-2009, 02:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1