+ Reply to Thread
Results 1 to 15 of 15

Change default Combobox value

  1. #1
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Change default Combobox value

    Happy Saturday all,

    I have bumped in an issue of finding a solution how to allow user to change default combobox value. Some details:

    Combobox is on a userform
    Combobox is in date format
    Please Login or Register  to view this content.
    Combobox style is set to fmStyleDropDownCombo and MatchRequired to False
    RowSource is linked to DATA!H2

    Basically I want to allow user to change the default combobox value when required.

    What am missing here?

    Thanks for your time!

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

    Re: Change default Combobox value

    This will set the combobox value to the date in cell H2 if that's what you are asking.

    ComboBox1.Value = Format(Sheets("DATA").Range("H2").Value, "dd/mm/yyyy")
    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 ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    Hi AlphaFrog and thanks for a speedy response.

    As I mentioned above combobox is already populated with the date from H2 using RowSource property.

    The problem is I cannot get to change this value in a combobox should I decide to enter a different date from the one in H2.

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

    Re: Change default Combobox value

    Enter a different date where? Where are you entering a new default date?

  5. #5
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    H2 is = TODAY()

    This is the date that is set as default in a combobox. Majority of transactions will be made on today's date, but there are occasions when we fall behind with transactions and need to key in some backdated transactions.

    Therefore, user loads the userform, today's date appears in a combobox, but user needs to be able to change today's date to any other date.

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

    Re: Change default Combobox value

    How do you want them to change that date?

    They could simply type in a new date in the combobox.

  7. #7
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    That is the problem that I cannot change it. It lets me delete the combobox default date, but when I start typing, combobox populates with 31/12/1899.

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

    Re: Change default Combobox value

    Now we're getting to the problem.

    If you have any Combobox1_??? procedures, can you post all of that code?

  9. #9
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    One finding - I have disabled formatting of a combobox and it lets me input any value, but I need to format it as date, otherwise combobox populates with general format 42287.

  10. #10
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    No, there are no other procedures other than macro grabs whatever date is in a combobox and places it in a cell in a database.

  11. #11
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    Please Login or Register  to view this content.

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

    Re: Change default Combobox value

    Please Login or Register  to view this content.
    Why are you using a Combobox instead of just a Textbox?

  13. #13
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Change default Combobox value

    Spot on! A million thanks mate!

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

    Re: Change default Combobox value

    You're welcome.

  15. #15
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Change default Combobox value

    Hi there,

    Take a look at the attached workbook and see if it's of use to you.

    It places today's date in a TextBox on a UserForm, allows you to edit the date if required, and generates an error message if an invalid date is entered.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    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] Change next ComboBox list based on previous ComboBox selection
    By SteveTheFish in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2015, 11:23 PM
  2. [SOLVED] Combobox Default values
    By Tortus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2014, 02:57 PM
  3. Userform Combobox to populate form: Can I change the order of the columns in the combobox?
    By CraigWiggins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2014, 12:14 PM
  4. Set a value from a combobox as default.
    By Lucky555 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2010, 09:59 PM
  5. Show ComboBox default value
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-15-2009, 01:23 PM
  6. Replies: 2
    Last Post: 11-17-2008, 09:14 PM
  7. Default Value in Combobox
    By VitoHGrind in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-11-2007, 01:04 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