V
V
Vlad2017-06-21 21:32:54
excel
Vlad, 2017-06-21 21:32:54

How to swap words in Excel cell?

I have values ​​​​in Excel in the cells in this form:
12-34-56
12-34-56
How to swap? pls tell me 56-34-12
?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Fedoryan, 2017-06-22
@AnnTHony

Using a formula in an adjacent cell:
Using a VBA macro:

Sub ReverseString()
    Dim WB As Workbook
    Dim WS As Worksheet
    Dim R As Integer
    
    Set WB = Excel.ActiveWorkbook
    Set WS = WB.Worksheets("reverse")
    
    ' Меняется столбец A1
    R = 1
    While (WS.Cells(R, 1).Value <> "")
        s = Split(WS.Cells(R, 1).Value, "-")
        WS.Cells(R, 1).Value = Join(Array(s(2), s(1), s(0)), "-")
        R = R + 1
    Wend
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question