Question for : Bernie Deitrick! Imorted Formats

  • Thread starter Thread starter CharlesF
  • Start date Start date
C

CharlesF

Hi Bernie

Thanks for the macro to sort out imported data.

There is one problem, though:

The dates are displayed as '11/04/04 or dd/mm/yy

When I run your macro the dates become 11/04/04 or mm/dd/yy

How do I correct this in the macro
 
Hi Charles,

Try adding three lines to Bernie's routine:

Sub MacroForCharles()
Dim myCell As Range
On Error Resume Next
For Each myCell In Selection
myCell.Value = myCell.Text
If IsDate(myCell.Value) Then ' <--- Added
line
myCell.Value = Format(myCell, "dd/mm/yy") ' <--- Added line
End If
' <--- Added line
Next myCell
End Sub
 
Hi Charles,

To avoid possible confusion caused by unintentional line wrap, the
procedure reads:

Sub MacroForCharles()
Dim myCell As Range
On Error Resume Next
For Each myCell In Selection
myCell.Value = myCell.Text
If IsDate(myCell.Value) Then
myCell.Value = Format(myCell, "dd/mm/yy")
End If
Next myCell
End Sub

---
Regards,
Norman

Norman Jones said:
Hi Charles,

Try adding three lines to Bernie's routine:

Sub MacroForCharles()
Dim myCell As Range
On Error Resume Next
For Each myCell In Selection
myCell.Value = myCell.Text
If IsDate(myCell.Value) Then ' <--- Added
line
myCell.Value = Format(myCell, "dd/mm/yy") ' <--- Added line
End If
' <--- Added line
Next myCell
End Sub
 

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

Back
Top