+ Reply to Thread
Results 1 to 17 of 17

Editing a code that sorts data for Dropdown in a UserForm

  1. #1
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Editing a code that sorts data for Dropdown in a UserForm

    Hi

    Not long ago pike gave me this code I was looking for:

    Please Login or Register  to view this content.
    But my problem is that it work for the active sheet that the userform is on.
    What I'm tryn to do is so it takes the data from a sheet called UserFormInfo
    And I tryed this but it gives me an error:

    Please Login or Register  to view this content.
    Is it not possible to use Sheets("UserFormInfo").Range in this code?
    Last edited by stojko89; 11-16-2011 at 08:07 AM.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Editing a code that sorts data for Dropdown in a UserForm

    In this line of code you've missed something

    Please Login or Register  to view this content.
    You need to insert Sheets("UserFormInfo")

    Steffen Thomsen

  3. #3
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Editing a code that sorts data for Dropdown in a UserForm

    For Each xCell In Sheets("UserFormInfo).Range("A1", Cells(Rows.Count, 1).End(xlUp))
    if you change that to:

    Please Login or Register  to view this content.
    Missing " " either side of UserFormInfo , you might have some more luck

  4. #4
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Ok so that was dumb
    But now I inserted the " " on both sides.
    Now when I try and run the UserForm that this is attached to it says Error and when I hit Debug it colors this line:

    Please Login or Register  to view this content.
    Any other idias?

  5. #5
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Post up a sample workbook and I can take a closer look.

  6. #6
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    This is the wb I'm working in. The Button Novo Naročilo in the rop right corner of the selected sheet calles the UserForm that has this dropdown inside under Dobavitelj: but you will see the error when you click the button to call the UserForm.

    Thanks for taking a look!
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Editing a code that sorts data for Dropdown in a UserForm

    the sheet your looking for doesn't exsist? so when you load the userform, it's looking for that sheet. I can't see no UserFormInfo? Is it supposed to be looking to a different workbook with the worksheet "UserFormInfo" or?

  8. #8
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    The Sheet is there it's just hidden. Use right click on sheet narocila Unhide and select Sheet UserFormInfo there are alot of sheets there.

  9. #9
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Editing a code that sorts data for Dropdown in a UserForm

    replace this in:

    Please Login or Register  to view this content.

    seems to load no errors for me now. if any problems come up just check what your calling your dim's etc as as in previous sheet userform nothing is in "A1" and it's always better to loop through cells

  10. #10
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Oh ****...damn I make problems where they don't need to be. I'm sorry kieranbop

    The count is sopose to start from cell A3 on sheet UserFormInfo

    so I change the cell in this code:

    Please Login or Register  to view this content.
    But the code you gave me with the numbers 65535 gives me an error and says object required and when I hit debug it color this line:

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Editing a code that sorts data for Dropdown in a UserForm

    what version are you using? and you will just have to put breakpoints in and you will see what's going wrong on your end, You need to check it's actually passing in values

  12. #12
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Excell 2007. Sure I'll try

  13. #13
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    When I put in the brake point and go line to line and when I get to this line:

    Please Login or Register  to view this content.
    It just says theres an error and I can't go on anymore.

  14. #14
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Try splitting this line in to two

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Steffen Thomsen

  15. #15
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Try it:
    Please Login or Register  to view this content.
    Last edited by nilem; 11-16-2011 at 07:51 AM.

  16. #16
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Editing a code that sorts data for Dropdown in a UserForm

    nilem

    The code you gave me. Left the Dropdown menu empty.

    Steffen Thomasen

    The code works great! As expected. I just changed The rage from A1:A to A3:A so it doesn't include those 2 cells.

    So thanks a lot man! And thank you all for your time and effort!

  17. #17
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Editing a code that sorts data for Dropdown in a UserForm

    Your welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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