如何在单元格中的文本之间添加垂直线,vba excel

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17621342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 22:12:23  来源:igfitidea点击:

How to add a vertical line between texts in a cell, vba excel

excelvbaline

提问by user2495069

For example, right now I have a cell like this:

例如,现在我有一个像这样的单元格:

enter image description here

enter image description here

But I want it like this.

但我想要这样。

enter image description here

enter image description here

Is it possible in excel VBA? Thank you!!

在excel VBA中可能吗?谢谢!!

回答by Eric J

Use the Text To Columns feature under the Data tab to break this into 2 columns. Then, if you really need a line, select the last column and add a left border.

使用“数据”选项卡下的“文本到列”功能将其分成 2 列。然后,如果您确实需要一行,请选择最后一列并添加左边框。

回答by Andy G

Is this data all in a single cell?

这些数据都在一个单元格中吗?

You will struggle to get it to align correctly, with or without VBA - each character occupies a slightly different width. EditedWell, it may behave better with a fixed-width font, as suggested by Tim Williams, but I still doubt that it will work consistently. (You could only insert spaces and the pipe '|' character, but it won't line up correctly.)

无论是否使用 VBA,您都很难使其正确对齐 - 每个字符占用的宽度略有不同。 编辑好的,正如蒂姆·威廉姆斯所建议的那样,使用固定宽度的字体可能会表现得更好,但我仍然怀疑它是否能始终如一地工作。(您只能插入空格和管道 '|' 字符,但它不会正确排列。)

This data belongs in two columns, and multiple rows, with a border between them.

此数据属于两列和多行,它们之间有边框。