+ Reply to Thread
Results 1 to 5 of 5

TextBox date

Hybrid View

ozhunter TextBox date 06-08-2011, 09:59 AM
Domski Re: TextBox date 06-08-2011, 10:28 AM
ozhunter Re: TextBox date 06-08-2011, 08:16 PM
Domski Re: TextBox date 06-09-2011, 04:04 AM
ozhunter Re: TextBox date 06-09-2011, 04:28 AM
  1. #1
    Registered User
    Join Date
    06-04-2011
    Location
    NSW Australia
    MS-Off Ver
    Excel 2007
    Posts
    43

    TextBox date

    Hello

    From my searches, this has been beaten to death, but I still can't get it to work.

    I have TextBox that the user enters a date as 8/6 and I want it to return the date format as 8-Jun-11 in the LinkedCell

    This is the code I have for the process so far. All i want to do at this point is have the date formatted as above in the LinkedCell of TextBox1.

    Thank you

    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    
    
        If KeyCode = 9 Then
        ComboBox1.Activate
        End If
        End Sub
        
    
    Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 9 Then
        ComboBox2.Activate
        End If
    
    End Sub
    Private Sub ComboBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 9 Then
        ComboBox3.Activate
        End If
    
    End Sub
    Private Sub ComboBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 9 Then
        TextBox1.Activate
        TextBox1.LinkedCell = Range(TextBox1.LinkedCell).Offset(1).Address
        ComboBox1.LinkedCell = Range(ComboBox1.LinkedCell).Offset(1).Address
        ComboBox2.LinkedCell = Range(ComboBox2.LinkedCell).Offset(1).Address
        ComboBox3.LinkedCell = Range(ComboBox3.LinkedCell).Offset(1).Address
    
        
        End If
    
    End Sub

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: TextBox date

    Text boxes always hold text values so you need to convert the text date into a serial date value using DateValue.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    06-04-2011
    Location
    NSW Australia
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: TextBox date

    Forgive my dumbness

    How would I incorporate that into the code to return the date in the format I require (d-mmm-yy) in the LinkedCell of the textbox.

    Thank you

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: TextBox date

    I guess you're using a text box off the Control Toolbox in which case I'm not sure you can without changing the contents of the text box as they are directly linked. If you used a userform rather than the control toolbox you'd be able to get round this more easily.

    Saying that someone else may be able to come up with something as I tend to avoid using the control toolbox.

    Dom

  5. #5
    Registered User
    Join Date
    06-04-2011
    Location
    NSW Australia
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: TextBox date

    Thanks Dom

    The deeper I get, the more problems I encounter with this. I've just discovered that I can't easlily sum the results of other textboxs doing things the way I was trying to. Might have to go back to the drawing board, me thinks

    Adam.

+ 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