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
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top