Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Smile Form - Hide Questions if answer not required according to age criteria

    I always find it difficult to give a meaningful title to my questions. I hope this one does the job.


    I have an excel form that I would like to streamline and make easier for users. There are a lot of questions that they do not need to answer according to the date of birth entered, so I would like to hide the irrelevant ones. I have looked at the validation function in Excel but I think this is more something that needs to be done in VB. I have attached a sample showing what I want to do.
    Attached Files Attached Files

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Kerry,

    Here's a roughed out User Form that shows how you can accomplish what you are after including:
    KerryUserForm.JPG
    • Calculating the Age (I used a routine from the internet which is a little more accurate than your formula).
    • Showing either Question 1 or Question 4 in the same space below the DOB:
    • Providing a group where only one answer can be selected.
    • Saving the data back to the worksheet.
    • Placing a button on the worksheet to run the form.


    If this is what you're after we can help you flesh out the rest of the solution if you are not familiar with VBA forms.

    Test File: KerryG - Validation Sample.xlsm

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,633
    Thanks
    115
    Thanked 647 Times in 590 Posts
    Kerryg,

    Since I had been working on a solution, I will post mine as well. The code accepts x or X for the checkboxes and validates any other value entered. The code will then hide the question (rows) based on the criteria you specify and will validate selections.

    HTH,
    Maud
    Attached Files Attached Files
    Last edited by Maudibe; 2015-03-27 at 21:33. Reason: forgot to disable line of code. revised file uploaded.

  4. #4
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Thank you so much for your response. What you and Maud have given me is a great start to work with. I will play with this over the next few days and get back to you if I have any questions. I am familiar with UserForms and can usually understand VB once written, but am not able to write it from scratch.
    Kind Regards Kerry

Posting Permissions

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