Closed Thread
Results 1 to 9 of 9

Need Help with VBA code that populates a dropdown in a userform conditionally

  1. #1
    Registered User
    Join Date
    01-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    83

    Need Help with VBA code that populates a dropdown in a userform conditionally

    Hello Excel Forum!

    I have some VBA code that populates a userform based on text and named ranges. The userform is a survey for clients to take and it works great. The only problem is that it's set for 8 responses (a dropdown selection and text entry). It's really easy to change the question in the survey and the possible responses in the dropdown but the problem is if i want to go from 8 questions to 7 then I have to go in and delete a bunch of code because the code tells it to populate the userform based on text in certain places. What I would like is a conditional statement which says "if there is text in that cell then use it" if there isn't anything there no big deal. Here's what I have. I would really appreciate any help.

    Thanks,

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    you have to use an if statement , like this :

    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Registered User
    Join Date
    01-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    83

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    Thanks xlbiznes but I couldn't get that to work. Basically I don't want to hard code "My Text" because I want to be able to easily change it. So if there is some text in C1 then
    Please Login or Register  to view this content.
    but if not then don't put anything in there.

    Thanks,

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    try this

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    83

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    Thanks xlbiznes! I think your part worked but I came up with an error code because of the same problem on my combobox. Can this be made conditional like the above??
    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    try this

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    83

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    clean survey.xlsm

    I couldn't get it to work. I'm probably missing something simple...

  8. #8
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    replace your Private Sub UserForm_Initialize() code with this and see what happens.

    Please Login or Register  to view this content.

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,110

    Re: Need Help with VBA code that populates a dropdown in a userform conditionally

    Opened in Commercial Services subforum so I'll close this one.
    Never use Merged Cells in Excel

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 03-19-2014, 02:34 PM
  2. Quick and Dirty : User selects from dropdown (sht1)...macro populates data from (sht2)
    By Joecruz749 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2013, 05:06 PM
  3. Help a rookie make a dropdown that populates a sheet.
    By DareArkin in forum Excel Formulas & Functions
    Replies: 23
    Last Post: 03-01-2013, 01:47 AM
  4. [SOLVED] How can I code a Userform to provide dropdown boxes to filter data?
    By gozzard in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2012, 05:28 PM
  5. Editing a code that sorts data for Dropdown in a UserForm
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-16-2011, 08:06 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