如何使用 multiple-line 自定义数字格式缩小列宽?
How to shrink column width with multiple-line custom number formats?
我发现了一个技巧,但是 Excel 不想完全合作...但也许有解决方法...?
我经常在 "tall row" 上得到 date/time(因为其他列是 multi-line):
...我想通过将 date/time 拆分为 2 行 来保存垂直 space,同时保持 [=93] =]单个数值 出于排序等原因:
我意识到这可以通过在 custom number format 中使用 ␊LineFeed
字符来实现,方法有以下两种:
方法#1: 在带有数字小键盘的键盘上:
Select 包含值的单元格。
按Ctrl+1打开Number Formats dialog.
选择 Custom
类别,然后在 Type:
文本框中:
- 输入 custom format 的第一部分,即。
yyyy-mm-dd
- 同时按住 Alt 在 numeric keypad 上输入
0010
,然后松开 Alt
- 输入自定义格式的第二部分,即。
HH:mm am/pm
点击回车。
在行之间拖动 headers 使行高两倍:
如果 Wrap Text
尚未打开,请在功能区的 主页 选项卡上单击它:
Alt + 0010
输入一个 ␊LineFeed
字符。
Note: Since Excel doesn't expect this character, the first line you enter in the Type
box will disappear as soon as you enter the ␊LineFeed
character. There's no way to see it within the dialog (without deleting the ␊LineFeed
), but it's still there.
方法 #2: 在没有数字小键盘的键盘上 and/or 使用 VBA:
在 VBA 编辑器中,在您的程序中,或在 即时 Window(Ctrl + G),你可以为 A1
设置 number format,例如:
Range("A1").NumberFormat="yyyy-mm-dd" & vbLf & "HH:mm am/pm"
...然后通过 VBA 或上面的步骤 #5 和 6 调整 row height and make sure Wrap Text
打开。
vbLf
(或Chr(10)
)表示VBA.
中的一个␊LineFeed
字符
我的问题:
这很酷,但似乎 Excel 仍然将值视为 单行上的一个长字符串.
这证明了:
- double-clicking 列 headers 到 AutoFit 列之间:
该专栏不再 "shrink"。
- double-clicking 行 headers 到 AutoFit 行之间:
该行没有"grow to double height".
手动将列拖动到更窄的尺寸。
Excel "thinks" 值不适合:
Any ideas for a workaround?
Perhaps there's a hack to force Excel to display partial values instead of ######
when a formatted numeric value doesn't fit?
谢谢!
确保勾选收缩以适应功能
转到:右键单击单元格 --> 设置单元格格式 --> 对齐 --> 缩小以适合
你必须收缩它。在此处查看 OP 的编辑:
Prevent hash signs (#) showing up in Excel without changing cell format or width
- 转到“设置单元格格式”对话框中的“对齐”选项卡。
- Select "Shrink to fit".
- Select "Wrap text".
- 单击"OK"。
Excel 仍会将列的大小自动调整为约 139 像素,但您可以将列宽拖动到约 71 像素并且仍会看到两条线。
对于此示例,您可以拆分两个单元格而不是这样做。在第一个单元格上,只输入没有时间的日期格式。在第二个单元格上,做一个公式=(the first cell)
,但把它放在时间格式。
我正在寻找一种方法来缩小它以适应单元格中的多行,但看起来我们没有在 2020 年自动执行此操作的技术。
我发现了一个技巧,但是 Excel 不想完全合作...但也许有解决方法...?
我经常在 "tall row" 上得到 date/time(因为其他列是 multi-line):
...我想通过将 date/time 拆分为 2 行 来保存垂直 space,同时保持 [=93] =]单个数值 出于排序等原因:
我意识到这可以通过在 custom number format 中使用 ␊LineFeed
字符来实现,方法有以下两种:
方法#1: 在带有数字小键盘的键盘上:
Select 包含值的单元格。
按Ctrl+1打开Number Formats dialog.
选择
Custom
类别,然后在Type:
文本框中:- 输入 custom format 的第一部分,即。
yyyy-mm-dd
- 同时按住 Alt 在 numeric keypad 上输入
0010
,然后松开 Alt - 输入自定义格式的第二部分,即。
HH:mm am/pm
- 输入 custom format 的第一部分,即。
点击回车。
在行之间拖动 headers 使行高两倍:
如果
Wrap Text
尚未打开,请在功能区的 主页 选项卡上单击它:
Alt + 0010
输入一个 ␊LineFeed
字符。
Note: Since Excel doesn't expect this character, the first line you enter in the
Type
box will disappear as soon as you enter the␊LineFeed
character. There's no way to see it within the dialog (without deleting the␊LineFeed
), but it's still there.
方法 #2: 在没有数字小键盘的键盘上 and/or 使用 VBA:
在 VBA 编辑器中,在您的程序中,或在 即时 Window(Ctrl + G),你可以为 A1
设置 number format,例如:
Range("A1").NumberFormat="yyyy-mm-dd" & vbLf & "HH:mm am/pm"
...然后通过 VBA 或上面的步骤 #5 和 6 调整 row height and make sure Wrap Text
打开。
vbLf
(或Chr(10)
)表示VBA.
␊LineFeed
字符
我的问题:
这很酷,但似乎 Excel 仍然将值视为 单行上的一个长字符串.
这证明了:
- double-clicking 列 headers 到 AutoFit 列之间:
该专栏不再 "shrink"。 - double-clicking 行 headers 到 AutoFit 行之间:
该行没有"grow to double height". 手动将列拖动到更窄的尺寸。
Excel "thinks" 值不适合:
Any ideas for a workaround?
Perhaps there's a hack to force Excel to display partial values instead of
######
when a formatted numeric value doesn't fit?
谢谢!
确保勾选收缩以适应功能
转到:右键单击单元格 --> 设置单元格格式 --> 对齐 --> 缩小以适合
你必须收缩它。在此处查看 OP 的编辑:
Prevent hash signs (#) showing up in Excel without changing cell format or width
- 转到“设置单元格格式”对话框中的“对齐”选项卡。
- Select "Shrink to fit".
- Select "Wrap text".
- 单击"OK"。
Excel 仍会将列的大小自动调整为约 139 像素,但您可以将列宽拖动到约 71 像素并且仍会看到两条线。
对于此示例,您可以拆分两个单元格而不是这样做。在第一个单元格上,只输入没有时间的日期格式。在第二个单元格上,做一个公式=(the first cell)
,但把它放在时间格式。
我正在寻找一种方法来缩小它以适应单元格中的多行,但看起来我们没有在 2020 年自动执行此操作的技术。