Thread: VB Date Format
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default VB Date Format

Hi,

Try it like this

Private Sub CommandButton1_Click()
If IsDate(ActiveCell.Value) Then
Me.TextBox1.Value = Format(ActiveCell.Value, "dd/mm/yyyy")
Else
MsgBox "The active cell isn't a valid date"
End If
End Sub

Mike

"Woodi2" wrote:

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.