date format problem??
maybe...
ws.Cells(iRow, 2).Value = Format(Me.TextBox2.Value, "dd/mm/yy")
But I'd use:
with ws.Cells(iRow, 2)
.numberformat = "dd/mm/yy"
.Value = Me.TextBox2.Value
end with
This assumes that textbox2 actually contains a date.
Steve wrote:
On Dec 27, 8:28 pm, Dave Peterson wrote:
What do you want in that cell:
ws.Cells(iRow, 2).Value = Me.TextBox2.Value
or
ws.Cells(iRow, 2).Value = Format(Date, "dd/mm/yy")
Steve wrote:
Hi there, hope you can help with this,,,
am using the code below with few problems,
the following line is showing in my spreadsheet as "TRUE" rather than
the date that gets entered
ws.Cells(iRow, 2).Value = Me.TextBox2.Value = Format(Date, "dd/mm/yy")
any help would be appreciated
Steve
Private Sub cmdadd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Lesson1")
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Please enter an Amount"
Exit Sub
End If
ws.Cells(iRow, 1).Value = Me.TextBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox2.Value = Format(Date, "dd/mm/yy")
ws.Cells(iRow, 3).Value = Me.TextBox3.Value
ws.Cells(iRow, 5).Value = Me.TextBox4.Value
ws.Cells(iRow, 6).Value = Me.TextBox5.Value
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox1.SetFocus
Unload Me
End Sub
--
Dave Peterson- Hide quoted text -
- Show quoted text -
Am looking for the date entered into the textbox to be placed into a
cell in the following format 'dd/mm/yy'
was hoping this would work, but from your replied question i guess i
am asking if the cell contains the date in the format specified, have
adjusted to the following but still no luck,
ws.Cells(iRow, 2).Value = Format(Me.TextBox2.Value = Date, "dd/mm/yy")
Steve
--
Dave Peterson
|