Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Dates in textboxes?

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have formated a text box to display dates with the following line in the textbox code:

    Private Sub TextBox1_Change()
    TextBox1.Text = Format(Range("$bi$4"), "dd-mmm-yy")
    End Sub

    It works fine until I print preview or print the page and then it goes back to date code and isnt formatted anymore.

    Anyone know how I can avoid this happening?

    TIA

    Dan.

  2. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Dan

    What are you printing? the UseForm?



  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Dave

    No the textbox is on a spreadsheet.

    I could make it so the date appears in the cell below the textbox and then make the textbox not print but I wondered if there was a way not to cheat for a change.

    Dan.

  4. #4
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Dan, I am unable to generate this problem with Excel 2000, the date prints just as show. Anyway try this.

    Private Sub TextBox1_Change()
    Dim strDate As String
    strDate = Range("A1")
    TextBox1 = Format(strDate, "dd/mmm/yy")
    End Sub

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Dave

    Im using XP so I dont know if its a bug in the new version.

    Your new code still does the same.

    Grrrr looks like Ill have to cheat (as per usual)

    Thanks

    Dan.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •