Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Excel, remove a special character from a date cell

I have a worksheet with a range of date cells however the values within the cells all have a "’" in front of the data. for example ’03/03/2023. ’04/08/2023 and so on

The apostrophe is throwing off my vlookups so I want to remove all of them however find and replace isn’t picking up the character?

I want to include the replace into my worksheet open event procedure

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Can anyone help ?

>Solution :

You can use this sub:

Sub removeApostrophFromDate(ws As Worksheet)
    Dim c As Range
    For Each c In ws.UsedRange
        If IsDate(c.Value) Then
            c.Value = CDate(c.Value)
        End If
    Next
End Sub

It checks whether the cell-value can be interpreted as date and then returns the correct value.

You can call it like e.g. this: removeApostrophFromDate thisworkbook.worksheets("mySheet")

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading