Im using the following code to convert text date to date format, but keep getting a type mismatch error, The date in text will look like 12/12/2012,Can anyone help?Please Login or Register to view this content.
Im using the following code to convert text date to date format, but keep getting a type mismatch error, The date in text will look like 12/12/2012,Can anyone help?Please Login or Register to view this content.
datevalue and cdate both use your regional settings for converting date strings-do your regional settings specify the date format you have in the cells?
Josie
if at first you don't succeed try doing it the way your wife told you to
Probably c.Value is already a date.
Cheers!
Tsjallie
--------
If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!
If you think design is an expensive waste of time, try doing without ...
They do match my regional settings and the date does look like a date but whenever I try to filter it doesnt give it as a month etc., as it can only see it as a text date & changing the cell format to date does not change the situation?
no leading/trailing spaces?
Change the line toand see what happens.Please Login or Register to view this content.
Last edited by Tsjallie; 08-19-2014 at 03:52 PM.
Why not use the function identified in your subject?
Please Login or Register to view this content.
JosephP no leading or trailing spaces, Tsjallie, where should I which line should I change?
Please attach a sample workbook.
You will get an error if any cells in column A cannot be converted to a date. For example if the column header is "Date".
Thanks,
Solus
Please remember the following:
1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.Highlight the code in your post and press the # button in the toolbar.2. Show appreciation to those who have helped you by clicking below their posts.
3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.
"Slow is smooth, smooth is fast."
I have attached a sample workbook, In the example there is a header line which was no in my test but will be in the finished worksheet.
Solus Rankin is right. The error comes from teh header.
When you use column("A") row 1 is the forst row which contains a header text.
Next row goes fine.
The origina;l worksheet does not have a header and still does not work but in this case how can I get around the header issue?
You can alter your code to skip row 1 line like this:
Please Login or Register to view this content.
Here is some simple error trapping.Please Login or Register to view this content.
or simpler
Please Login or Register to view this content.
Why covert a date to a date?
@Tsjalie
Look at workbook OP posted. They're in date format but stored as text.
Why not just select the column, Data > Text to columns, Finish?
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks