简体   繁体   English

Excel自定义日期格式未显示在编辑栏和数据透视表中

[英]Excel custom date format not showing in formula bar and pivot table

I'm trying to override the date format of cells that is 01/10/2018 to Jan/10/2018 in a sheet that is the pivot table source. 我试图在作为数据透视表源的工作表中覆盖单元格的日期格式,即01/10/2018到Jan / 10/2018。 In the cells, it shows Jan/10/2018, but in the formula bar it shows 01/10/2018. 在单元格中显示为Jan / 10/2018,但在编辑栏中显示为01/10/2018。

In the pivot table it also shows 01/10/2018 even when overriding it with a macro. 在数据透视表中,即使被宏覆盖,它也会显示01/10/2018。

I tried using an apostrophe in front of the Jan/10/2018 but then I get a 46772 number in the cell. 我尝试在2018年1月10日之前使用撇号,但随后在单元格中得到了46772号。

Any ideas? 有任何想法吗? Please help! 请帮忙!

One problem: The data is cleaned on opening in VBS so I cannot use a formula manually 一个问题:在VBS中打开时会清除数据,因此我无法手动使用公式

Sub Format_Date ()

Selection.NumberFormat = "mmm-dd-yyyy"

End Sub

Try applying this code to your date and it should do the work. 尝试将此代码应用于您的日期,它应该可以完成工作。

In the Formula Bar, a date will show according to your computer's setting for the "Short date". 在编辑栏中,日期将根据计算机的“短日期”设置显示。

In Control Panel > Clock, Language and Region > Region and Language you can set these defaults for your computer. 在控制面板>时钟,语言和区域>区域和语言中,可以为计算机设置这些默认值。

The Excel "short date" format will always be displayed in the formula bar. Excel的“短日期”格式将始终显示在编辑栏中。 In the screenshot below, you can see my regional settings. 在下面的屏幕截图中,您可以看到我的区域设置。 The Excel cell has today's date, formatted as a "Long Date". Excel单元格具有今天的日期,格式为“长日期”。 The formula bar shows the "Short date", which is determined by the computer's regional settings. 编辑栏显示“短日期”,该日期由计算机的区域设置确定。

So, no, you cannot change the way the date shows in the formula bar, unless you are prepared to change your computer settings for "short date". 因此,不可以,除非您准备更改“短日期”的计算机设置,否则无法更改日期在编辑栏中显示的方式。 This will then apply to all applications that use that date format, which may be way more than just Excel. 然后,这将适用于所有使用该日期格式的应用程序,而不仅仅是Excel。

点击此链接获取图片示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM