After creating a sheet of data and running it thru power query/transpose, copying the output to another sheet, sheet still has the data in a table format, and then trying to change the date format it will not work. Using the two methods below, neither one changes the date format.
But if I enter data into a spreadsheet and try using the following code on the manually entered data the format id=s changed. I have also tried to click on cell ‘C3’ and change the format by using format cell and choosing ‘mmm-dd’ as an option with no change.
It seems that after running a sheet thru powerquery and trying to reformat the date either thru VBA or right click on cell and change format nothing changes. Can someone help me understand what I have to change.
PowerQuery code below:
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
Type = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Time", type time}, {"Courts", Int64.Type}, {"Teams", type text}}),
Pivot = Table.Pivot(Table.TransformColumnTypes(Type, {{"Date", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(Type, {{"Date", type text}}, "en-US")[Date]), "Date", "Teams")
in
Pivot
My 2 ways of trying to change date format using VBA
Way 1:
Change date cells from text to date and format them
Set rng = Sheets("Template").Range(Cells(3, 3), Cells(3, LastCol))
For Each Cell In rng
Cell.Number = "MMM-DD"
Next Cell
Way2:
With Sheets("Template")
.Range("c3:e3").Value = CDate(.Value)
.Range("c3:e3").NumberFormat = "mmm-dd"
But if I enter data into a spreadsheet and try using the following code on the manually entered data the format id=s changed. I have also tried to click on cell ‘C3’ and change the format by using format cell and choosing ‘mmm-dd’ as an option with no change.
It seems that after running a sheet thru powerquery and trying to reformat the date either thru VBA or right click on cell and change format nothing changes. Can someone help me understand what I have to change.
PowerQuery code below:
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
Type = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Time", type time}, {"Courts", Int64.Type}, {"Teams", type text}}),
Pivot = Table.Pivot(Table.TransformColumnTypes(Type, {{"Date", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(Type, {{"Date", type text}}, "en-US")[Date]), "Date", "Teams")
in
Pivot
My 2 ways of trying to change date format using VBA
Way 1:
Change date cells from text to date and format them
Set rng = Sheets("Template").Range(Cells(3, 3), Cells(3, LastCol))
For Each Cell In rng
Cell.Number = "MMM-DD"
Next Cell
Way2:
With Sheets("Template")
.Range("c3:e3").Value = CDate(.Value)
.Range("c3:e3").NumberFormat = "mmm-dd"