简体   繁体   English

如何删除Excel文档中每一列中特殊字符之后的所有内容,并将两个单词从一个单元格划分为两个单独的单元格?

[英]How to delete everything after special charcter in each column in Excel document and divide two words from one cell to two separate cells?

I have excel document with one column. 我有一栏的Excel文档。 It looks like this: 看起来像这样:

 car /VIj+
 car, cars /VIj-
 home, homes /VKjsah+
 homeless, homeless /VKjsbh+
.
.
.

And I need to delete everything after symbol / including symbol / in each column. 我需要删除每列中的符号(包括符号)之后的所有内容。 Then I need to divide cells with two words in to the separate cells and delete symbol , which is between words. 然后,我需要将具有两个单词的单元格划分为单独的单元格,并删除单词之间的symbol。 Can somebody help me? 有人可以帮我吗?

Assuming that your data are in single column and there are empty columns right to the data column. 假设您的数据在单个列中,并且数据列右边有空列。 If so you could run this code for selected range containing data: 如果是这样,您可以针对包含数据的选定范围运行此代码:

Sub Solution()
    Dim tmpArr
    Dim Cell As Range
    For Each Cell In Selection.Cells
        tmpArr = Split(Split(Cell, "/")(0), ",")
        Cell.Resize(1, 1 + UBound(tmpArr)) = tmpArr
    Next
End Sub

The following picture presenting results of the macro. 下图显示了宏的结果。

在此处输入图片说明

暂无
暂无

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

相关问题 如何突出显示两个Excel单元格,每个单元格中包含多个单词 - How to highlight two excel cells contain multiple words in each cell 在A列中的空白单元格之后将两行单元格添加到Excel电子表格中 - Adding two rows of cells to an Excel spreadsheet after a blank cell in column A 如何使用java将一个excel单元格拆分为两个单元格 - How to split one excel cell into two cells using java 如何将汇总列表从一个单元格分离为 Excel 中的单独单元格 - How do I separate a aggregate list from One Cell Into Separate Cells In Excel 如果嵌套if语句中的一个或两个单元格为空,如何在一个单元格中返回0? - How to return 0 in a cell if one or two cells are empty from nested if statement? 在Excel中,如何在两个单独的工作表中匹配两个不同的值之后有条件地格式化单元格? - In Excel, how do I conditionally format a cell after matching two distinct values across two separate worksheets? 从 Excel 中的一个单元格文本字符串中提取一或两个单元格的经度和纬度 - Extract longitude and latitude to either one or two cells, from one cell text string in Excel Excel - 将列中的值分成两列 - Excel - Separate values from column into two columns 当两个工作表中的单元格匹配且具有单独的特定值时,如何更改单元格值? - How to change a cell value when cells from two worksheet match and a separate specific value? Excel VBA如何获取两个单独的非一致相邻单元格之间未使用的单元格的地址增量 - Excel VBA how to get address delta of cell(s) not used between two separate non-congruent adjoining cells
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM