Date format error

hermithead

New Member
Joined
Sep 7, 2009
Messages
37
OK Im one step away from completing my spreadsheet and I have this problem which has been ongoing throughout development.

The dates that I am pasting into my spreadsheet are formatted as dd.mm.yyyy , the macro that I run to check that the dates are correct will only work if the date is in dd/mm/yyyy format. So I do a simple Find and Replace ie "." for "/".
The problem is after the Find and Replace some not all of the dates are rearranged as: mm/dd/yyyy. This of course throws out my data validation.

Note, I've tried Format cells>Date but the macro still doesnt work and only recongnises "/". (Ive included the macro below in case theres a workaround there instead).

<!-- BEGIN TEMPLATE: bbcode_code -->
Code:
  <style> .alt2 font { font: 11px monospace !important; color: #333 !important; } </style>  
[FONT=Arial][SIZE=2][COLOR=#000000]'Checks date range'

Sheets("Calc").Select
Range("A9").Select
Dim iMonth As Integer

A:

iMonth = Month(ActiveCell.Value)

If iMonth = 7 Then

ActiveCell.Offset(1, 0).Select
GoTo A

Else

    If ActiveCell.Value = "" Then

    MsgBox "All dates are within range", vbInformation

    Else

    MsgBox "This is not July data", vbCritical

    Exit Sub
    
    End If

End If[/COLOR][/SIZE][/FONT] 
 <!-- END TEMPLATE: bbcode_code -->
<!-- / message --> <!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --> <!-- END TEMPLATE: ad_showthread_firstpost_sig --> <!-- controls -->
progress.gif
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Rather than Find/Replace, try using Data>TextToColumns and on the third screen of the TTC dialog setting the import date format to DMY. You can code this up too.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,851
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top