Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8255981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:42:50+00:00 2026-06-08T01:42:50+00:00

I have data in an excel sheet in the following format: ItemCode DeliveryDate 5456987

  • 0

I have data in an excel sheet in the following format:

ItemCode                            DeliveryDate
5456987                              24.01.2009
5456988                                          
5456989                              12.24.2009
5456990                              12/24/2009

I have stored the values of DeliveryDate in an array. I need to make decision on basics of date and then print the result in a new sheet. So I have to convert the values into array:

Dim current as Date, highest as Date, result() as Date
For Each itemDate in DeliveryDateArray
    current = CDate(itemDate)
    if current > highest then
         highest = current
    end if
    ' some more operations an put dates into result array
Next itemDate
'After activating final sheet...
Range("A1").Resize(UBound(result), 1).Value = Application.Transpose(result)

Unfortunately, CDate() function throws the error:

Run-time error ’13’:

Type mismatch

Is there a function in VBA which can:

  • parse string with any date format and return a date object to work with.
  • return an empty date object, if the string is empty or malformed (for comparison in the loop).

Edit:

To reproduce the error, simply run
myDate = CDate("24.01.2009")

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:42:51+00:00Added an answer on June 8, 2026 at 1:42 am

    Try using Replace to see if it will work for you. The problem as I see it which has been mentioned a few times above is the CDate function is choking on the periods. You can use replace to change them to slashes. To answer your question about a Function in vba that can parse any date format, there is not any you have very limited options.

    Dim current as Date, highest as Date, result() as Date 
    For Each itemDate in DeliveryDateArray
        Dim tempDate As String
        itemDate = IIf(Trim(itemDate) = "", "0", itemDate) 'Added per OP's request.
        tempDate = Replace(itemDate, ".", "/")
        current = Format(CDate(tempDate),"dd/mm/yyyy")
        if current > highest then 
            highest = current 
        end if 
        ' some more operations an put dates into result array 
    Next itemDate 
    'After activating final sheet... 
    Range("A1").Resize(UBound(result), 1).Value = Application.Transpose(result) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel sheet with data similar to the following Reg_id Name Product_Owned
Assume I have an Excel 2007 sheet with the following data in column A:
I am working on writing the data into Excel sheet in c#. I have
I have a dynamic range in an Excel sheet. DATA_TABLE =OFFSET(DATA!$B$3,0,0,COUNTA(DATA!$B:$B)-1,0) I want to
I'm having trouble with some Excel data validation. On one sheet, I have a
I have following data in excel table r1 r2 r3 r4 r5 v1 v2
I have data stored in three columns of Excel Column A: Serial Number Column
I have an excel document with multiple sheets. Each sheet contains data of separate
I'm importing data from an Excel sheet on to a DataTable using the following
I am getting following error while exporting data to excel sheet ERROR: Message :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.