VB Date Format
You would do it like this and I still recommend you check for a valid date
Private Sub CommandButton1_Click()
If IsDate(ActiveCell.Offset(0, -1).Value) Then
Me.TextBox1.Value = Format(ActiveCell.Offset(0, -1).Value, "dd/mm/yyyy")
Else
MsgBox "The active cell isn't a valid date"
End If
End Sub
Mike
"Woodi2" wrote:
Thanks Bob, thats great.
How would I tie it in with this
Me.TextBox1.Value = ActiveCell.Offset(0, -1).Value.
Where would the code be added to change the format?
Apologies but since writing it I need it to be offset 1 cell.
Thanks
Ian
"Bob Phillips" wrote:
Private Sub CommandButton1_Click()
Me.TextBox1.Value = Format(ActiveCell.Value, "dd.mm/yy")
End Sub
--
__________________________________
HTH
Bob
"Woodi2" wrote in message
...
I have a userform that has a command button that displays a date within an
active cell and displays this date in textbox 1.
Private Sub CommandButton1_Click()
Me.TextBox1.Value = ActiveCell.Value
End Sub
The date in the cell is in the format dd/mm/yyyy. When it is displayed in
the textbox it displays it as mm/dd/yyyy.
How can I change this around to the format dd/mm/yyyy?
I have tried
Me.TextBox1.Value = Format(Date, "dd/mm/yy")
but that displays the current date, not what is in the cell.
|