Date format issue

I

Ian

Hi all

I posted a variation on this request a couple of days back, but no-one seems
able (or willing) to solve my problem. Thsi issue is this:

I need to have the option of entering a date into a form either manually, or
from a command button. I then need that date to be transferred to a
worksheet cell. I then need to be able to compare other cells with that date
to determine if the other dates have passed.

I'm currently using a textbox on the form, but this shows the date as
mm/dd/yyyy instead of the required dd/mm/yyyy. The date on the sheet is
fine.
If I use Format(date, "dd/mm/yyyy)) to correctly display the date on the
form, the transferred date is then in text format and can no longer be
compared to on the sheet.

Any ideas how I can get round this?
 
R

ramesh_rajamoni

using ADO jet oledb driver -with hdr=yes set, when i try to read a excel
sheet containing numeric values in all rows from row1 , the first
numeric row is expected to appear as column header in the grid i try to
display in vb6.0, instead first row data is missing and default F1,F2..
headers are displayed. If I change first row data as text , that row
data is correctly displayed.
 
R

ramesh_rajamoni

whenever u use format function of vb it returns a string , in this case
u need to set the format of the excel cell to which u r exporting the
date value.
if u have in a textbox some date value convert it (if necessary) to
date datatype using cdate() in vb and export to a excel cell which is
formatted as date type - use format cells option.

-RR
 
I

Ian

Thanks for the suggestion, Bill, but this is not the issue as the date in
the cell appears correctly.

The VBA Date command seems to format as mm/dd/yyyy by default. Although I
can reformat using Format(Date, "dd/mm/yyyy"), the resulting data is then
text which is no use when transferred to my sheet.
 
I

Ian

Perfect!

I can leave TextBox1.Value = Format (Date, "dd/mm/yyyy") assigned to the
command button, then Range("E2") = Cdate(TextBox1.Value) is exactly what I
needed to convert the transferred data to date format.

Thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top