+ Reply to Thread
Results 1 to 5 of 5

Userform formatting

  1. #1
    Trefor
    Guest

    Userform formatting


    I have a UserForm textbox point to a cell on a sheet. The cell is date
    formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
    m > 12 then the format changes to d/m/yyy. Is it possible to change the date
    format on the Userform or make it obey the sheet formatting?

    --
    Trefor

  2. #2
    Tom Ogilvy
    Guest

    RE: Userform formatting

    break the assignment of controlsource and
    load the textbox with code. Then you can format it just like the cell

    Private Sub Userform_Initialize()
    Textbox1.Value = worksheets("Sheet1").Range("A1").Text
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Trefor" wrote:

    >
    > I have a UserForm textbox point to a cell on a sheet. The cell is date
    > formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
    > m > 12 then the format changes to d/m/yyy. Is it possible to change the date
    > format on the Userform or make it obey the sheet formatting?
    >
    > --
    > Trefor


  3. #3
    Trefor
    Guest

    RE: Userform formatting

    Tom,

    Thanks for the reply, that does indeed fix one problem but breaks another. I
    would like to edit the text box on the userform and have it update the cell
    on the spreedsheet. Now that I have made you selected change it does not
    update the cell anymore. Sorry I am new to Userforms so this is probably
    really simple!

    --
    Trefor


    "Tom Ogilvy" wrote:

    > break the assignment of controlsource and
    > load the textbox with code. Then you can format it just like the cell
    >
    > Private Sub Userform_Initialize()
    > Textbox1.Value = worksheets("Sheet1").Range("A1").Text
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Trefor" wrote:
    >
    > >
    > > I have a UserForm textbox point to a cell on a sheet. The cell is date
    > > formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
    > > m > 12 then the format changes to d/m/yyy. Is it possible to change the date
    > > format on the Userform or make it obey the sheet formatting?
    > >
    > > --
    > > Trefor


  4. #4
    Tom Ogilvy
    Guest

    RE: Userform formatting

    You would use the event code of the textbox and write the change back to the
    sheet.

    Private Sub TextBox1_Change()
    Dim dt As Date, rng As Range
    Set rng = Worksheets("Sheet1").Range("A1")
    If IsDate(TextBox1.Text) Then
    On Error Resume Next
    dt = CDate(TextBox1.Text)
    rng.Value = dt
    On Error GoTo 0
    End If
    End Sub

    this would go in the userform module.
    --
    Regards,
    Tom Ogilvy


    "Trefor" wrote:

    > Tom,
    >
    > Thanks for the reply, that does indeed fix one problem but breaks another. I
    > would like to edit the text box on the userform and have it update the cell
    > on the spreedsheet. Now that I have made you selected change it does not
    > update the cell anymore. Sorry I am new to Userforms so this is probably
    > really simple!
    >
    > --
    > Trefor
    >
    >
    > "Tom Ogilvy" wrote:
    >
    > > break the assignment of controlsource and
    > > load the textbox with code. Then you can format it just like the cell
    > >
    > > Private Sub Userform_Initialize()
    > > Textbox1.Value = worksheets("Sheet1").Range("A1").Text
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Trefor" wrote:
    > >
    > > >
    > > > I have a UserForm textbox point to a cell on a sheet. The cell is date
    > > > formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
    > > > m > 12 then the format changes to d/m/yyy. Is it possible to change the date
    > > > format on the Userform or make it obey the sheet formatting?
    > > >
    > > > --
    > > > Trefor


  5. #5
    Trefor
    Guest

    RE: Userform formatting

    Tom,

    You have been very helpful thankyou very much.

    --
    Trefor


    "Tom Ogilvy" wrote:

    > You would use the event code of the textbox and write the change back to the
    > sheet.
    >
    > Private Sub TextBox1_Change()
    > Dim dt As Date, rng As Range
    > Set rng = Worksheets("Sheet1").Range("A1")
    > If IsDate(TextBox1.Text) Then
    > On Error Resume Next
    > dt = CDate(TextBox1.Text)
    > rng.Value = dt
    > On Error GoTo 0
    > End If
    > End Sub
    >
    > this would go in the userform module.
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Trefor" wrote:
    >
    > > Tom,
    > >
    > > Thanks for the reply, that does indeed fix one problem but breaks another. I
    > > would like to edit the text box on the userform and have it update the cell
    > > on the spreedsheet. Now that I have made you selected change it does not
    > > update the cell anymore. Sorry I am new to Userforms so this is probably
    > > really simple!
    > >
    > > --
    > > Trefor
    > >
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > break the assignment of controlsource and
    > > > load the textbox with code. Then you can format it just like the cell
    > > >
    > > > Private Sub Userform_Initialize()
    > > > Textbox1.Value = worksheets("Sheet1").Range("A1").Text
    > > > End Sub
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > >
    > > > "Trefor" wrote:
    > > >
    > > > >
    > > > > I have a UserForm textbox point to a cell on a sheet. The cell is date
    > > > > formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
    > > > > m > 12 then the format changes to d/m/yyy. Is it possible to change the date
    > > > > format on the Userform or make it obey the sheet formatting?
    > > > >
    > > > > --
    > > > > Trefor


+ Reply to Thread

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