Thread: VB Date Format
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default VB Date Format

ActiveCell.Offset(0, -1) = CDate(TextBox1.Value)

and format the cell as required.


--
__________________________________
HTH

Bob

"Woodi2" wrote in message
...
Thanks Guys, very helpful.

How do I do this when writing back to the sheet.
i.e. i write back using another commandbutton as follows
ActiveCell.Offset(0, -1) = TextBox1.Value
How do i add into this code to change the data entry to dd/mm/yyyy.
i.e. if a user enters the date in textbox 1 as 5/3/09, how can I convert
that to 05/03/2009.
Thanks again

"Bob Phillips" wrote:

Private Sub CommandButton1_Click()
Me.TextBox1.Value = Format(ActiveCell.Offset(0, -1).Value, "dd.mm/yy")
End Sub


--
__________________________________
HTH

Bob

"Woodi2" wrote in message
...
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.