vba 文本到列功能无法正常工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27050448/
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
Text to columns function not working properly?
提问by Luis
I′ve this simple text inside a cell - this is an example of many with the same issue - and I need to put that into columns, delimited by spaces. When I do that, the function just do the work with the first sentence, finishing in "deck", and stops there so I′m loosing half of my information or more If I′ve more lines. I can′t understand why it′s happening, and I worked for hours on a macro that depends on this information as I wrongly assumed this would be plain easy.
我在一个单元格中有这个简单的文本 - 这是许多具有相同问题的示例 - 我需要将其放入以空格分隔的列中。当我这样做时,函数只是用第一句话完成工作,在“甲板”中完成,然后停在那里,所以如果我有更多的行,我会丢失一半或更多的信息。我不明白为什么会这样,我在一个依赖于这些信息的宏上工作了几个小时,因为我错误地认为这很容易。
(.52) Hold revenue. Need to set up deck.
(.89) Hold revenue. Need to contact purchaser.
Thanks for your help!
谢谢你的帮助!
采纳答案by Luis
Ok I got the answer so I′ll post it myself.
好的,我得到了答案,所以我会自己发布。
I need to separate based on spaces and carriage returns, but I was just trying with spaces thinking there was no way to add carriage returns as a separator. I was wrong. When you select the function, you′ve a field called "other". There you need to add "Control + J", which is the shortcut for carriage returns. With that fix, the result is as expected.
我需要根据空格和回车符进行分隔,但我只是尝试使用空格,认为无法添加回车符作为分隔符。我错了。当您选择该功能时,您将拥有一个名为“其他”的字段。在那里你需要添加“Control + J”,这是回车的快捷方式。通过该修复,结果如预期。
回答by Dave.Gugg
Assuming your column is A and starts in row 1, create a second column with the following formula in B1:
假设您的列是 A 并从第 1 行开始,在 B1 中使用以下公式创建第二列:
=SUBSTITUTE(A1,CHAR(10)," ")
Copy down the entire B column. Copy and paste this column as values. Now use the Text to Columns functionality, but use space as the delimiter.
复制整个 B 列。将此列复制并粘贴为值。现在使用 Text to Columns 功能,但使用空格作为分隔符。