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