ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform (https://www.excelbanter.com/excel-programming/362799-userform.html)

johnboy

Userform
 
I have a textbox on a userform which reads a date from a cell in spreadsheet.
Problem I am getting is each time I open the form the format of the date
changes in both the the textbox and cell. ie if cell is format dd/mm/yyyy the
Textbox shows mm/dd/yyyy. When I open the form again, it is the oposite of
the first result?
I have tried using Format eg Textbox1.Text = Format(Cells(1,2).value,
"dd/mm/yyyy") but the date still shows different format for Textbox & Cell!
Can anyone explain why this should happen & how I show to the Texbox the
cell value & format without changing it please??

Many thanks
--
JB

Tom Ogilvy

Userform
 
Don't link the checkbox to the cell. Load the checkbox with code.

always convert a string date with Cdate - it will pay attention to your
local settings.

--
Regards,
Tom Ogilvy



"johnboy" wrote:

I have a textbox on a userform which reads a date from a cell in spreadsheet.
Problem I am getting is each time I open the form the format of the date
changes in both the the textbox and cell. ie if cell is format dd/mm/yyyy the
Textbox shows mm/dd/yyyy. When I open the form again, it is the oposite of
the first result?
I have tried using Format eg Textbox1.Text = Format(Cells(1,2).value,
"dd/mm/yyyy") but the date still shows different format for Textbox & Cell!
Can anyone explain why this should happen & how I show to the Texbox the
cell value & format without changing it please??

Many thanks
--
JB


johnboy

Userform
 
and it was that simple! thanks very much Tom - really appreciated!
--
JB


"Tom Ogilvy" wrote:

Don't link the checkbox to the cell. Load the checkbox with code.

always convert a string date with Cdate - it will pay attention to your
local settings.

--
Regards,
Tom Ogilvy



"johnboy" wrote:

I have a textbox on a userform which reads a date from a cell in spreadsheet.
Problem I am getting is each time I open the form the format of the date
changes in both the the textbox and cell. ie if cell is format dd/mm/yyyy the
Textbox shows mm/dd/yyyy. When I open the form again, it is the oposite of
the first result?
I have tried using Format eg Textbox1.Text = Format(Cells(1,2).value,
"dd/mm/yyyy") but the date still shows different format for Textbox & Cell!
Can anyone explain why this should happen & how I show to the Texbox the
cell value & format without changing it please??

Many thanks
--
JB



All times are GMT +1. The time now is 08:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com