+ Reply to Thread
Results 1 to 3 of 3

Textbox and Option Buttons - If Textbox has a Value then an Option Button must be selected

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    Taunton, Somerset
    MS-Off Ver
    Excel 2010
    Posts
    12

    Question Textbox and Option Buttons - If Textbox has a Value then an Option Button must be selected

    Hi all

    I am really struggling to get this code working. It seems so simple but is giving me a headache.

    I have a userform with various information that needs to be input over a period of time. At one point though a textbox will have a date put in it and this will mean that a selection of an option button must also be done. I have put 2 option buttons in a frame so that only 1 can be selected.

    When the userform is submitted I want it to check if there is a value in the textbox and if so that one of the option buttons has also been selected. If they aren't then I want it to give me a msgbox to tell the user that they need to complete the option buttons.


    This is the code I have:


    'Private Sub CommandButton1_Click()
    '
    '
    '
    'If Me.TextBox1.Value Is Nothing And (Me.OptionButton1.Value = False _
    ' Or Me.OptionButton2.Value = False) Then
    '
    'MsgBox "Please indicate whether this initial contact was attempted or actual"
    '
    'End If
    '
    '
    'Worksheets("Sheet1").Select
    '
    'With ActiveSheet
    '
    'Range("A2").Value = UserForm1.TextBox1.Value
    'Range("B2").Value = UserForm1.OptionButton1.Value
    'Range("C2").Value = UserForm1.OptionButton2.Value
    '
    'End With
    '
    '
    '
    'UserForm1.Hide
    '
    'End Sub


    Thanks in advance.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Textbox and Option Buttons - If Textbox has a Value then an Option Button must be sele

    Me.TextBox1.Value=""
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    05-17-2013
    Location
    Taunton, Somerset
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Textbox and Option Buttons - If Textbox has a Value then an Option Button must be sele

    Thanks nathansav

    Solved the initial issue and have been able to sort the rest.

    Cheers

+ 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. [SOLVED] Option buttons to prduce a sentence into textbox
    By molesy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-31-2014, 08:52 AM
  2. [SOLVED] option button to disable textbox
    By molesy in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-25-2014, 09:02 AM
  3. Looping through userform option buttons, textbox and labels
    By Gal403 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2014, 09:03 AM
  4. Changing Textbox From Grey to Enabled and Back Again With Option Buttons
    By stuu3270 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2013, 04:59 AM
  5. [SOLVED] passing Option button result to textbox
    By tigerdel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-29-2012, 02:35 AM

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