简体   繁体   English

Excel-在某些字符之间显示单词

[英]Excel - present word between certain characters

I am trying to split some data up but stuck! 我正在尝试拆分一些数据,但卡住了! I have some data which comes out like the below: 我有一些数据如下所示:

USERNAME Full Name Department

USERNAME First Initial Surname Department

USERNAME Full Name Department

I have tried numerous items such as trim then can pull out words however some peoples full names are 3 words and most of them are 2 words so this kinda breaks it all. 我尝试了很多项目,例如修剪,然后可以拉出单词,但是有些人的全名是3个单词,而大多数人是2个单词,所以这有点破了。

I have also tried substituting the double spaces so it breaks it up like so 我也尝试过替换双倍空格,所以它像这样分解

##USERNAME#######Full Name######Department###########

##USERNAME###First Initial Surname Department#

##USERNAME###########Full Name#####Department#####

But still unsure how I can pick up the words between the hashes. 但是仍然不确定如何在哈希之间找到单词。

Help really appreciated :) 帮助真的很感激:)

If you have a text file with the raw data, separate the raw data using either of a TAB, a semi-colon, or a comma. 如果您有一个带有原始数据的文本文件,请使用TAB,分号或逗号分隔原始数据。 Pick something you do not already have in your file. 选择文件中尚未包含的内容。 Semi-colon usually works for me. 分号通常对我有用。

Then, open it as a CSV (comma-separated values) file in Excel. 然后,在Excel中将其作为CSV(逗号分隔值)文件打开。

在Excel中以CSV格式打开文件

It will try to parse the file automatically. 它将尝试自动分析文件。 If it doesn't succeed, it will ask you what character you want to use as a separator. 如果未成功,它将询问您要用作分隔符的字符。

You mentioned double spaces seperating your data, that's your ticket in. 您提到用双空格分隔数据,这就是您的问题。

Let's say you've got "USERNAME David Brossard DEPT" in Cell A2. 假设您在单元格A2中有“ USERNAME David Brossard DEPT”。

In B2, let's FIND the first double space: 在B2中,让我们查找第一个双精度空格:

=FIND("  ",A2)

In C2, let's FIND the second double space: 在C2中,让我们查找第二个双精度空格:

=FIND("  ",A2,B2+1)

In D2, we'll grab everything in between: 在D2中,我们将获取介于两者之间的所有内容:

=MID(A2,B2+2,C2-(B2+2))

There you go! 你去!

Alternatively, you can write it all in one formula, in B2: 另外,您也可以在一个公式中用B2写下全部内容:

=MID(A2,FIND("  ",A2)+2,FIND("  ",A2,FIND("  ",A2)+1)-(FIND("  ",A2)+2))

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

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