Results 1 to 4 of 4

Why Won't The Date Display Correctly In A Userform Combobox?

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Why Won't The Date Display Correctly In A Userform Combobox?

    Hi all,

    this is a minor irritation more than a major problem but I'm flummoxed by it all the same. Rylo and ProtonLeah helped me with some code (thanks guys) for using a userform and spin button to amend data - the code is below
    Private Sub UserForm_Initialize()
    Me.SpinButton1.Max = Worksheets("data").Cells(Rows.Count, 1).End(xlUp).Row
    Me.SpinButton1.Min = 1
    SpinButton1.Value = SpinButton1.Max
    
    Private Sub SpinButton1_Change()
    Me.ComboBox1.Value = Worksheets("Data").Range("A" & Me.SpinButton1.Value).Value
    Me.ComboBox2.Value = Worksheets("Data").Range("B" & Me.SpinButton1.Value).Value
    Me.ComboBox3.Value = Worksheets("Data").Range("C" & Me.SpinButton1.Value).Value
    Me.TextBox1.Value = Worksheets("Data").Range("D" & Me.SpinButton1.Value).Value
    Me.TextBox2.Value = Worksheets("Data").Range("E" & Me.SpinButton1.Value).Value
    Me.TextBox3.Value = Worksheets("Data").Range("F" & Me.SpinButton1.Value).Value
    Me.TextBox4.Value = Worksheets("Data").Range("G" & Me.SpinButton1.Value).Value
    Me.TextBox5.Value = Worksheets("Data").Range("H" & Me.SpinButton1.Value).Value
    Me.TextBox6.Value = Worksheets("Data").Range("I" & Me.SpinButton1.Value).Value
    Me.TextBox8.Value = Worksheets("Data").Range("J" & Me.SpinButton1.Value).Value
    Me.TextBox7.Value = Worksheets("Data").Range("K" & Me.SpinButton1.Value).Value
    Application.StatusBar = SpinButton1.Value
    
    'If ComboBox1.Value = "" Then
    'MsgBox " There are no more records to show... "
    'End If
    
    End Sub
    Here's the problem - the date in combobox2 won't display in the format I would like (DD-MMM-YY) - the data in Column B of the "Data" worksheets is just dates (formatted as DD-MMM-YY) - when the userform loads however, the date (eg 5 Jul 12) is displayed as 7/5/12

    I tried using a change
    Private Sub ComboBox2_Change()
    ComboBox2.Value = Format(ComboBox2.Value, "DD-MMM-YY")
    End Sub
    but this changes the displayed date to 7 May 12 and gives me a "Huh?" moment. What am I missing here?

    Cheers,

    AJ
    Last edited by ScotyB; 07-08-2012 at 06:31 PM. Reason: To mark as SOLVED
    Always grateful for the help here - thanks.

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