Hi and thanks for reading this.
Imagine you have a form with a textbox. This textbox is there to add a date into a cell within a work sheet. Im in the UK so i would enter a date of dd/mmmm/yyyy.
The code behind it would be something like..
let sheets("sheet1".cells(1,1) = textbox1.value
or
let sheets("sheet1".cells(1,1) = textbox1.text
Now - this works to a point. When I enter dd/mmmm/yyyy, by the time I get to the month, excel is switching the date and the month. eg. I enter say 1/2/2003 (1st Feb 2003) Excel then swaps it on the sheet to 2nd Jan 2003.
Typing the date into the textbox as a long date format solves this, but the form created requires many dates and those dates have to be on the sheets correctly for lookup tables to work.
I have read MSDN where they mention CDate, but my VBA is ultra basic and when I have tried to experiment I generate errors. I have also done searches on the web that gives many lines of code. I want something simple.
Can anyone give a VBA novice a helping hand?
Cheers
Terry
ps, I have looked at calender controls and DTpicker. Although they would solve the problem, the forms we use are very limited on space so only textboxes will do.
Imagine you have a form with a textbox. This textbox is there to add a date into a cell within a work sheet. Im in the UK so i would enter a date of dd/mmmm/yyyy.
The code behind it would be something like..
let sheets("sheet1".cells(1,1) = textbox1.value
or
let sheets("sheet1".cells(1,1) = textbox1.text
Now - this works to a point. When I enter dd/mmmm/yyyy, by the time I get to the month, excel is switching the date and the month. eg. I enter say 1/2/2003 (1st Feb 2003) Excel then swaps it on the sheet to 2nd Jan 2003.
Typing the date into the textbox as a long date format solves this, but the form created requires many dates and those dates have to be on the sheets correctly for lookup tables to work.
I have read MSDN where they mention CDate, but my VBA is ultra basic and when I have tried to experiment I generate errors. I have also done searches on the web that gives many lines of code. I want something simple.
Can anyone give a VBA novice a helping hand?
Cheers
Terry
ps, I have looked at calender controls and DTpicker. Although they would solve the problem, the forms we use are very limited on space so only textboxes will do.