Macro to Find dates and replace with Text.

uhguy

Board Regular
Joined
Aug 22, 2008
Messages
79
Hi,

Not sure if this is even possible but maybe it is and Im just not creative enough to create.

I would like to be able to find dates in column C dates and replace the cell with text representing the month.

For instance if cell C9 has 1/1/13, the macro would replace the data in there with "'January"

So far this is what I have,

Code:
Range("C9").Select
    ActiveCell.FormulaR1C1 = "=MONTH(RC[0])"
    Range("C9").Select
    Selection.NumberFormat = "@"
    Selection.NumberFormat = "mmmm;@"
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False


The problem is that the value of that cell is actually = 1, not "January".
The other problem is that I need to happen to all cells in column C, my macro only would change the cell i selected, in this case C9

Thanks in advance!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
This requires you to select the range with dates you want to convert to month names, but you can easily adapt it to your needs:
Code:
Sub ReplaceDateWithMonth()
'Select the range before running this macro
For Each c In Selection
    If IsDate(c) Then
        c.Value = MonthName(Month(c.Value))
    End If
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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