+ Reply to Thread
Results 1 to 7 of 7

Sort issues while using userform

  1. #1
    Forum Contributor
    Join Date
    07-30-2017
    Location
    texas
    MS-Off Ver
    2016
    Posts
    123

    Sort issues while using userform

    greetings,

    i have a worksheet with a userform, which i am having issues with. when the userform fields have been filled in and then submitted, on sheet1 it properly enters the information onto the sheet. the problem is that the date (which needs to be in the format of mmmm d) does not sort as it should. it will only sort if i manually select the date cell of the last entry on sheet1. Once i select the date cell, the sheet is correctly and immediately sorted. on sheet1 in visual basic, i have code that deals with the change in sheet data that should initiate the sorting. my goal is that i would like for it to automatically sort once the submit button is pressed on the userform.



    any help would be greatly appreciated! i am unable to come up with a solution to this problem



    see attached file
    Attached Files Attached Files

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,280

    Re: Sort issues while using userform

    You disabled events in your userform code, which is why your Change event is not responding. I'd suggest you move the sort code to a separate routine in a normal module, then call it from everywhere you need it - including the userform code.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    07-30-2017
    Location
    texas
    MS-Off Ver
    2016
    Posts
    123

    Re: Sort issues while using userform

    after moving the worksheet_change code to a regular module and then try to call the sub from the userform, i get an error "compile error: argument not optional". any help would be appreciated.

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Sort issues while using userform

    Picked this up again this morning after seeing it late last night, I hope my input is helpful.
    Firstly, you are using a 'structured table' for your data storage which is good, however you are using range handling techniques and not table related methods, therefore not taking full advantage of tables.
    You had excess code in Worksheet_Change events which was conflicting with UserForm code - best practice is to not have any on-sheet code, conditional formatting or formula - contain it all within your UserForm/Module codes - it prevents conflict.
    With your combobox you have hard coded the items (using .additem) - when you develop larger apps you will find it better to have tables of 'defaults' it is then far easier to add/delete than having to modify your code.
    As said I hope you find this helpful and not critism.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  5. #5
    Forum Contributor
    Join Date
    07-30-2017
    Location
    texas
    MS-Off Ver
    2016
    Posts
    123

    Re: Sort issues while using userform

    I never complain when the projects work! Thanks so much for cleaning up the code and fixing my mess. Works like a champ!

    david

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Sort issues while using userform

    thanks for the feedback and added rep point - glad to have helped.

  7. #7
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Sort issues while using userform

    Hello.
    It is common for some things to not work properly in some PC locales.

    And that is the case of the introduction of the dates in the cells: I enclose a way to give generality to the topic.

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Userform Issues
    By Rosco88 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2015, 09:24 AM
  2. Issues with SORT
    By toeragh in forum Excel General
    Replies: 2
    Last Post: 09-07-2014, 12:20 AM
  3. [SOLVED] Sort Issues
    By Will03 in forum Excel General
    Replies: 4
    Last Post: 08-05-2014, 12:26 PM
  4. VBA Custom Sort Order Issues
    By Warderbrad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2012, 04:38 PM
  5. Data Sort Issues
    By navanax1 in forum Excel General
    Replies: 8
    Last Post: 10-08-2012, 03:37 PM
  6. Excel 2007 : Table Sort issues
    By BradB in forum Excel General
    Replies: 2
    Last Post: 04-08-2009, 12:22 PM
  7. My Sort has Issues
    By A Waller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2005, 03:05 PM

Tags for this Thread

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