Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
And what is the format of ws.Cells(freerownum, 7) ?
RBS "Hazel" wrote in message ... Hi What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In VBA if a string can be interpreted as a US formatted date, it will be.
Try this With ws.Cells(freerownum, 7) .Value = DateValue(Tb1) .NumberFormat = "dd/mm/yy" End With -- Regards, Tom Ogilvy "Hazel" wrote: Hi What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Everybody's help much appreciated, I have used and tried Tom's solution and it works perfectly even on the other 3 textboxes that are used to input dates on the sheet - hopefully because I save all the snippets of code etc that help me I might never again need anything about UK / US date formatting. -- Many thanks hazel "Tom Ogilvy" wrote: In VBA if a string can be interpreted as a US formatted date, it will be. Try this With ws.Cells(freerownum, 7) .Value = DateValue(Tb1) .NumberFormat = "dd/mm/yy" End With -- Regards, Tom Ogilvy "Hazel" wrote: Hi What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perhaps its the variables. The following:
Sub hazel() Set ws = Sheets("sheet1") freerownum = 1 Tb1 = Now ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") End Sub puts: 9/8/2007 in the cell - clearly in day/month/year format. -- Gary''s Student - gsnu200736 "Hazel" wrote: Hi What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
TB1 is a string, not a date.
Plus, I would check on what is so clear. -- Regards, Tom Ogilvy "Gary''s Student" wrote: Perhaps its the variables. The following: Sub hazel() Set ws = Sheets("sheet1") freerownum = 1 Tb1 = Now ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") End Sub puts: 9/8/2007 in the cell - clearly in day/month/year format. -- Gary''s Student - gsnu200736 "Hazel" wrote: Hi What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is Tb1?
RBS "Hazel" wrote in message ... Hi What is wrong? with the line below ws.Cells(freerownum, 7).Value = Format(Tb1, "dd/mm/yy") On the sheet it converts it to US Format ("mm/dd/yy") Why? -- Many thanks hazel |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
permanent conversion of 1904 date format to 1900 date format | Excel Worksheet Functions | |||
change date format dd/mm/yyyy to Julian date format? | Excel Worksheet Functions | |||
convert serial date format to normal date format | Excel Discussion (Misc queries) | |||
code to convert date from TEXT format (03-02) to DATE format (200203) | Excel Programming | |||
Change a date in text format xx.xx.20xx to a recognised date format | Excel Programming |