My data provider has changed several things in the .XLSX file I get. I have added a new sub to fix the data according to the model this application expects:
Sub Feb27FixModel()
ActiveSheet.Range("H2").End(xlDown).NumberFormat = "dd-mmm-yyyy" 'change format of Processed Date
Dim colNum As Integer
colNum = ActiveSheet.Rows(1).Find(what:="Legacy code", lookat:=xlWhole).Column
' Done twice to insert 2 new cols
ActiveSheet.Columns(colNum + 1).Insert
ActiveSheet.Columns(colNum + 1).Insert
' New col headings
ActiveSheet.Cells(1, colNum + 1).Value = "Origin Code"
ActiveSheet.Cells(1, colNum + 2).Value = "Jurisdiction Code"
Range("A1").Select
ActiveCell.FormulaR1C1 = "County Name"
Range("B1").Select
ActiveCell.FormulaR1C1 = "State Abbreviation"
ActiveWorkbook.Save
End Sub
Everything works EXCEPT the result of the 1st line above. In the active worksheet, column H has a header row value of "Processed Date" and the H2 cell and cells below it are stored as General with values like 11/15/2016. I need to change all the dates to a custom date as dd-mmm-yyyy. The statement below fails to get this done for me:
ActiveSheet.Range("H2").End(xlDown).NumberFormat = "dd-mmm-yyyy"
EDIT (01March2017):
Thanks to the answer from @Jeeped below, I added another statement and this is the code that was the solution:
With ActiveSheet
.Range(.Cells(2, "H"), .Cells(.Rows.Count, "H").End(xlUp)).NumberFormat = "dd-mmm-yyyy"
.Range(.Cells(2, "H"), .Cells(.Rows.Count, "H").End(xlUp)).Value = ActiveCell.Text
End With
EDIT (02March2017):
I made a mistake yesterday. In debugging, I must have had a good cell selected in the worksheet at a breakpoint; hence, refering to ActiveCell.Text "sort of worked". It had the effect of replicating the Text to be "14-Oct-2016" in EVERY row for column H (except the first row). This was minimally acceptable.
What I really need is a statement that will take the Text of all rows of column H and change the stored value from displaying as 10/14/2016 to 14-Oct-2016, etc. It is not enough to just change the format to custom. I need to change the stored values too. I don't know how to do that.