+ Reply to Thread
Results 1 to 16 of 16

Case Select not catching right column in Userform's Combobox

  1. #1
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Case Select not catching right column in Userform's Combobox

    Good day,
    I have the following code in my Userform:

    Please Login or Register  to view this content.
    I have different sheet but some information will be repeated in these sheets. When I bring my Userform on Case 6, it doesn't populate the right case Selection. Why is this code not functioning well?

    I mean I am closing my "With" therefore should not be looking in my Sheets("Evaluation") on case 6 when I trigger Case 6 in Sheets("Pre-Solicitation").
    Last edited by Excelnoub; 05-08-2014 at 12:41 PM.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Case Select not catching right column in Userform's Combobox

    Hi,

    Maybe this :

    Please Login or Register  to view this content.
    When working with different sheets, make sure that you use .Range(xxx) instead of Range(xxx) to "link" the range to the proper sheet. Otherwise, the range refers to the active sheet.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    Runtime Error '381':
    Could not set the List Property. Invalid Property Array Index.

  4. #4
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Case Select not catching right column in Userform's Combobox

    Maybe an other hint :
    Let's say you are in your sheet "Pre-solicitation", cell A1. This is your ActiveCell.
    Your Select Case doesn't validate if the ActiveCell is in sheet "Pre-sollicitation" or "Evaluation" or "Report". It only checks the column of the ActiveCell.

    You might need to add an other verification such as

    Please Login or Register  to view this content.
    To verify in which sheet is your ActiveCell.

    Am I clear?

  5. #5
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Case Select not catching right column in Userform's Combobox

    Runtime Error '381':
    Could not set the List Property. Invalid Property Array Index
    In which sheet are your named range?

  6. #6
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    Sheets("Control")

  7. #7
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Case Select not catching right column in Userform's Combobox

    Ok, then this is not the problem an d you do not need to use .Range("xxxx").
    Best practice, I would use Sheets("Control").Range("xxx").

    What about my other suggestion ?

  8. #8
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    Testing it right now

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

    Re: Case Select not catching right column in Userform's Combobox

    What is the code meant to do?

    Is it supposed to populate ComboBox1 based on which sheet is active and which cell is selected in that sheet?

    If it is then perhaps something like this, untested, code would work.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  10. #10
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    The:

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

  11. #11
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    lol actually both code work Thank you guys I will make sure next time I check these things next time

    Thank you...

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

    Re: Case Select not catching right column in Userform's Combobox

    Your With in that code doesn't do anything.

  13. #13
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    You're right, thank you Norie

  14. #14
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    Actually to make it more easier to add information afterward to my range I have modified my code to the following.

    Please Login or Register  to view this content.

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

    Re: Case Select not catching right column in Userform's Combobox

    No need for 3 variables for the last row(s).

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

  16. #16
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Case Select not catching right column in Userform's Combobox

    Once again Norie you have made my life less complicated.

    Works Perfect


+ 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] Using userform for Select Case
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-14-2014, 09:00 AM
  2. [SOLVED] ComboBox Select Case Question
    By yoko21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2013, 06:49 AM
  3. [SOLVED] Excel Userform: Populate other controls (i.e. textbox & combobox) based on combobox select
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 04:50 PM
  4. Select Case and UserForm Buttons
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-29-2011, 11:35 PM
  5. Combobox via Select Case
    By AnthonyWB in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2011, 05:19 PM

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