+ Reply to Thread
Results 1 to 13 of 13

Faulty combox code???? Help

  1. #1
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Faulty combox code???? Help

    Hi,

    Can anyone help with my conundrum? Ive asked my code to populate Combobox15 with "CORDA006" when Combobox has a value of/between 370 and 400
    and when combobox5 is populated with 75. It runs with no errors but doesn't seem to do anything?




    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Faulty combox code???? Help

    How do you know this part of the code is actually running? There is code before this part and it may be exiting the procedure or doing something that prevents this part from executing.


    On another note: Application.EnableEvents has no effect on UserForm controls.

    Suppressing Events In UserForms
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Faulty combox code???? Help

    its under the user form initialise instruction. I should delete Application. Enable Events? Ill check the code and get back

  4. #4
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Faulty combox code???? Help

    No change. Here's the code for the userform, its quite extensive but is mostly the contents of comboboxes. The code I am confused about is at the end

    Please Login or Register  to view this content.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Faulty combox code???? Help

    This should do it.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Faulty combox code???? Help

    Probably won't...

    ComboBox1 will have its ListIndex = -1 at this stage so the value will be 0. The code really should be in the Change event for a Combobox, not too sure if it should be CB1 or CB5, or possibly both.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Faulty combox code???? Help

    Looking at your initialization code, you populate the combobox lists, but don't set any values for them. So it would seem they have no values when you open the userform, and the IF statement would never be true.

    EDIT: do what cytop said and put the IF in both Combobox1 and Combobox5 _Chnage procedures

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 09-27-2016 at 07:51 AM.

  8. #8
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Faulty combox code???? Help

    Hi bakerman, I've just updated using your code and got this?
    Attached Images Attached Images

  9. #9
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Faulty combox code???? Help

    Hi Aplhafrog, is this correct?? it doesn't seem to do anything@
    Attached Images Attached Images
    Last edited by bralew; 09-27-2016 at 08:06 AM.

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Faulty combox code???? Help

    Might I suggest that you post the actual file itself, please?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  11. #11
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Faulty combox code???? Help

    yeah no worries, ill put it up now.
    Attached Files Attached Files

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Faulty combox code???? Help

    None of the values in combobox1 are between 370 and 400.

    I think I have mentioned before that you really should consider loading your controls from ranges to make maintenance easier. Even if you do need to hardcode them, you can make the code more efficient by using arrays

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Faulty combox code???? Help

    I'll do that in future, that looks much better, thanks ever so much. It works fine, I've enough work to keep me busy now Thank you

+ 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: 2
    Last Post: 05-12-2015, 03:46 PM
  2. Update Combox with Slicer items - getting error on Combox.listcount
    By Bigkx06 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-12-2014, 02:47 PM
  3. [SOLVED] combox code to find opposite value
    By mak_pj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2013, 02:33 PM
  4. Excel Code run when combox list item is selected.
    By cllaguno in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-15-2013, 07:58 AM
  5. Convert a faulty code to it's equv error
    By hero96559 in forum Excel General
    Replies: 4
    Last Post: 08-08-2009, 11:13 AM
  6. Faulty Code
    By gizoku00 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-08-2008, 04:09 PM
  7. Faulty Page Tabs
    By philipallen in forum Excel General
    Replies: 0
    Last Post: 03-24-2006, 10:40 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