Thread: [Solved] Date formatting
View Single Post
 
Old 08-12-2011, 12:02 PM
Catalin.B Catalin.B is offline Windows Vista Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

check this link for instructions on how to set up your first macro...
http://office.microsoft.com/en-us/ex...138.aspx?CTT=1

repeat the operations in video, after you stop the macro, press visual basic button as picture attached, and replace your newly created macro with this macro: (your visual basic window should look like in picture attached...) Next step is to press the little green triangle highlighted in red in picture attached, it will do your job in less than 30 seconds. But attention, if you have wrong data in AD column, as i posted before, ( remember: "AD1, there is a text: "Nov-09" !! this is just a piece of text to excel, cannot recognize it as a date...There is no way excel can recognize it as 11/3/2009" )...you have to reenter data in those cells. Good luck !

Sub RecalculateCells()
Dim i As Integer
Application.ScreenUpdating = False

For i = 1 To 1000 'if you need more than 1000 rows, change here
ActiveSheet.Cells(i, 4).Select '4 means column D
Selection.NumberFormat = "mm/dd/yyyy" 'choose format for D column
ActiveCell.Value = ActiveCell.Value ' recalculate cells selected
Next i

For i = 1 To 1000 'if you need more than 1000 rows, change here
ActiveSheet.Cells(i, 30).Select '30 means column AD
Selection.NumberFormat = "mm/dd/yyyy" 'choose format for D column
ActiveCell.Value = ActiveCell.Value ' recalculate cells selected
Next i

ActiveSheet.Cells(1, 4).Activate
Application.ScreenUpdating = True
End Sub
Reply With Quote