LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 176
Default Code Needed

Hi

I Run WinXP with Excel 2K


I have created a form to enter data into a worksheet. This works fine. The
first entry in the form is a date. Normally in Excel when I type a date I
just enter the day followed by a backslash followed by the month (23/9) and
enter and it returns 23/09/2009. However, when I type into the first text box
of the form 23/9 it just stays like that. I assume that this is because it is
a text box and is not formatted as a date format. What I would like is for
the user to be able to enter 23/9 into the first box and it display
23/9/2009. I dont even know if this is possible but I am hoping someone can
supply me with some code that will do this.

This is my current code for the form:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("DATA")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.TxtDate.Value) = "" Then
Me.TxtDate.SetFocus
MsgBox "Please enter a the date"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.TxtDate.Value
ws.Cells(iRow, 2).Value = Me.TxtWeek.Value
ws.Cells(iRow, 3).Value = Me.TxtShift.Value
ws.Cells(iRow, 4).Value = Me.TxtCrew.Value
ws.Cells(iRow, 5).Value = Me.TxtNonProdDel.Value
ws.Cells(iRow, 6).Value = Me.TxtCalShift.Value
ws.Cells(iRow, 7).Value = Me.TxtInput.Value
ws.Cells(iRow, 8).Value = Me.TxtOutput.Value
ws.Cells(iRow, 9).Value = Me.TxtDelays.Value
ws.Cells(iRow, 10).Value = Me.TxtCoils.Value
ws.Cells(iRow, 11).Value = Me.TxtThrd.Value
ws.Cells(iRow, 12).Value = Me.TxtEps.Value
ws.Cells(iRow, 13).Value = Me.TxtType.Value
ws.Cells(iRow, 14).Value = Me.TxtNpft.Value
ws.Cells(iRow, 15).Value = Me.TxtScrp.Value
ws.Cells(iRow, 16).Value = Me.TxtDwnGrd.Value
ws.Cells(iRow, 17).Value = Me.TxtRawCoil.Value
ws.Cells(iRow, 18).Value = Me.TxtInj.Value
ws.Cells(iRow, 19).Value = Me.TxtSlowRun.Value
ws.Cells(iRow, 20).Value = Me.TxtPlanOutput.Value
ws.Cells(iRow, 21).Value = Me.TxtBudgOutput.Value


'clear the data

Me.TxtDate.Value = ""
Me.TxtWeek.Value = ""
Me.TxtShift.Value = ""
Me.TxtCrew.Value = ""
Me.TxtNonProdDel.Value = ""
Me.TxtCalShift.Value = ""
Me.TxtInput.Value = ""
Me.TxtOutput.Value = ""
Me.TxtDelays.Value = ""
Me.TxtCoils.Value = ""
Me.TxtThrd.Value = ""
Me.TxtEps.Value = ""
Me.TxtType.Value = ""
Me.TxtNpft.Value = ""
Me.TxtScrp.Value = ""
Me.TxtDwnGrd.Value = ""
Me.TxtRawCoil.Value = ""
Me.TxtInj.Value = ""
Me.TxtSlowRun.Value = ""
Me.TxtPlanOutput.Value = ""
Me.TxtBudgOutput.Value = ""
Me.TxtDate.SetFocus


End Sub

------------------------------------------------------------------------
Private Sub cmdClose_Click()
Unload Me


End Sub

---------------------------------------------------------------------------

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub


Thanks


John
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function or Code Needed Jennifer Excel Worksheet Functions 6 December 10th 08 02:59 PM
Help needed with VBA code Sam Hill Excel Discussion (Misc queries) 1 May 9th 06 02:29 PM
VBA code help needed Martin Excel Discussion (Misc queries) 3 April 28th 06 09:28 AM
VLOOKUP code needed please j4ymf Excel Worksheet Functions 4 March 12th 06 07:48 PM
VBA code to sum a row: syntax needed [email protected] Excel Discussion (Misc queries) 1 July 11th 05 06:41 PM


All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"