Adjusting data in cell

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,835
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I formatted a column to custom 'dd mmm yyyy' which is mostly what's wanted but some of the data has year only.
So I've been entering 'dd mmm 1999'. Now I don't like it as there's too many, and having the year only is tidier.
Changing the Format to text allows the year only but changes the full formatted Date to a number.
Some values also don't have a year so "07 Apr 19?" is used.
Is there a format where I can have all those without (as someone said) having a leading apostrophe?
And I think I need to remove the value for each cell, reformat it, and reapply the value.
 
If that is correct, then this macro will change Column A ( change if necessary) to what I described above.

VBA Code:
Sub test()
Dim c As Range, s
For Each c In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
If IsDate(c) And c <> "" Then
    c.NumberFormat = "dd mmm yyyy"
Else
    s = Split(c)
    If s(2) = "??" Then
        c = StrConv(s(1), vbProperCase)
    Else
        c = s(2)
    End If
End If
Next
End Sub
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Scott, Col B would be dd mmm yyyy or however much is available from Col A.
Alex, is there a Text to column button ? The only way I know is to r-Click column, Then Format Cells - Number - Text. And I think it only works if the column (cell?) is empty.
I made the mistake of formatting Column to Custom "dd mmm yyyy" thinking it would leave anything it couldn't format as it was.
 
Upvote 0
Alex, is there a Text to column button ?
There certainly is ;)

You will find more information here >
Converting Text to Numbers or Converting Dates is more common useage but in this case we want to convert the displayed value to Text.

1707376351377.png



1707376583383.png
 

Attachments

  • 1707376414038.png
    1707376414038.png
    40.3 KB · Views: 2
Upvote 0
A "just put what I type in" category would be really useful.
It already exists - that is the "Text" option. If you format the column to cells to "Text" before you make your entries, it will always enter exactly what you type in with no conversions.
Of course, if you use that, you are then entering text entries and not date entries.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

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