+ Reply to Thread
Results 1 to 3 of 3

Dates Not working in a userform comobox

Hybrid View

k.tanton Dates Not working in a... 11-29-2022, 10:08 AM
CheeseSandwich Re: Dates Not working in a... 11-29-2022, 10:20 AM
beyond Excel Re: Dates Not working in a... 11-29-2022, 11:07 AM
  1. #1
    Registered User
    Join Date
    05-03-2019
    Location
    East Yorkshire
    MS-Off Ver
    365
    Posts
    69

    Dates Not working in a userform comobox

    Thanks for any help that can be given.

    When I use the Amend button and the userform appears and I use the combobox, I see dates as I should. When I select the date it changes to the Excel number for that date. What do I need to do to keep the date format in the combobox when selected.

    Please be gentle with me, I am doing this using a video tutorial and changing parts as I go. So if you can be specific it would help.

    Again thank you to anyone that can help

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2503
    Posts
    1,459

    Re: Dates Not working in a userform comobox

    Add the below piece of code:
    Private Sub ComboBoxFind_Change()
        ComboBoxFind.Value = Format(ComboBoxFind.Value, "dd/mm/yyyy")
    End Sub
    Making your code:
    Private Sub ComboBoxFind_Change()
        ComboBoxFind.Value = Format(ComboBoxFind.Value, "dd/mm/yyyy")
    End Sub
    
    Private Sub CommandButton1_Click()
        Dim TargetRow As Integer
        
        TargetRow = Application.WorksheetFunction.Match(CDbl(ComboBoxFind), Sheets("Moorhouse").Range("RentFindAmend"), 0)
        MsgBox TargetRow
    End Sub
    If things don't change they stay the same

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

    Re: Dates Not working in a userform comobox

    Hello. Another approach would be to leave the following in the userform:

    Private Sub UserForm_Initialize()
    ComboBoxFind.RowSource = ""
    ComboBoxFind.List = Range("RentFindAmend").Value
    End Sub
    
    Private Sub CommandButton1_Click()
    Dim TargetRow As Long
    TargetRow = Application.WorksheetFunction.Match(CDbl(CDate(ComboBoxFind)), Sheets("Moorhouse").Range("RentFindAmend"), 0)
    MsgBox TargetRow
    End Sub
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped 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. [SOLVED] Creating a Loop to check multiple textboxes and comobox
    By Catsonheat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-13-2019, 12:06 PM
  2. Help with comobox linked to previous combobox (dependancy) on a userform
    By TL33 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2015, 06:29 PM
  3. Change a comobox format in a form
    By smash96 in forum Excel General
    Replies: 5
    Last Post: 03-21-2014, 02:25 PM
  4. Populating a listbox or comobox (validation?) with unique values from large range
    By starfailure in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2013, 11:41 PM
  5. [SOLVED] VBA Userform: Use value from Comobox to populate a Listbox
    By devolg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2013, 11:59 PM
  6. comobox
    By afdmello in forum Excel General
    Replies: 2
    Last Post: 11-26-2005, 03:10 PM
  7. comobox-name as variable
    By Christian Galbavy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2005, 09:06 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