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

StackOverflow https://stackoverflow.com/questions/16638481

  •  29-05-2022
  •  | 
  •  

I have excel document with one column. 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. 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.

enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top