+ Reply to Thread
Results 1 to 6 of 6

Userform displays in (MM/DD/YYY) format, when spreadsheet stores as (DD/MM/YYYY) format

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Userform displays in (MM/DD/YYY) format, when spreadsheet stores as (DD/MM/YYYY) forma

    Thanks very much, that worked perfectly, greatly appreciated.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Userform displays in (MM/DD/YYY) format, when spreadsheet stores as (DD/MM/YYYY) forma

    Hello David

    You might like to consider simplifying this. As I intimated a loop would be better used to populate your text boxes
    I alos see that every time you populate them you are calling the Function MyRange. Which means that you are calling it 43 times. Which is rather a waste of time and resources.

    Just create an Excel dynamic range name called 'MyRange'
    =OFFSET(Plan!$A$2,0,0,COUNTA(Plan!$A:$A),1)

    Create a Public Variable in the VBA
    Public myrange As Range
    In your Userform initialise event
    Private Sub UserForm_Initialize()
        Set myrange = Sheet1.Range("MyRange")
        For Each cell In myrange
            ComboBox1.AddItem cell
        Next
    End Sub
    and now your ComboBox change event is

    Private Sub ComboBox1_Change()
        Dim x As Long
        On Error GoTo 1
        
        For x = 1 To 7
            If x <> 7 Then
               UserForm2.Controls("TextBox" & x) = myrange.Find(ComboBox1).Offset(0, x + 1)
               Else
               UserForm2.Controls("TextBox" & x) = Format(myrange.Find(ComboBox1).Offset(0, x + 1),"dd/mm/yyyy")
            End If
        Next x
    
        TextBox43 = myrange.Find(ComboBox1).Offset(0, 1)
        Label1 = ComboBox1
    1 End Sub
    Last edited by Richard Buttrey; 08-27-2012 at 10:43 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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