Tuesday, June 15, 2010

Reversing a Cell Contents with VBA - MS Excel

Reversing active cell contents using the vba code. Place this code in to a standard module. Select the cell you want to reverse and run the macro.

Sub Reverse()
    If Not ActiveCell.HasFormula Then
        sRaw = ActiveCell.Text
        sNew = ""
        For J = 1 To Len(sRaw)
            sNew = Mid(sRaw, J, 1) + sNew
        Next J
        ActiveCell.Value = sNew
    End If
End Sub

No comments:

Post a Comment