Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    reverse text (all)

    Link to post provided by HansV

    this is similar to <post:=185,798>post 185,798</post:>
    where I requested the following............

    I need to reverse the contents of all filled cells in column 1
    ie- Cell a1 contains "edcba hgf" that should read "abcde fgh"----the problem arises from importing from foreign language.
    Letters spaces and numbers in cells are all allowed.
    The change I request now is that numbers shall not be reversed ie "edcba 25/75 hgf " should read "abcde 25/75 fgh" and not "abcde 52/57 fgh" in addition cells which contain numbers only shall not be changed/reversed.
    Thanx
    Smbs

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: reverse text (all)

    Try this macro:

    Sub ReverseText()
    Dim oCell As Range
    Dim strText As String
    Dim strArr
    Dim i As Integer
    For Each oCell In Selection
    strText = ""
    strArr = Split(oCell.Value)
    For i = LBound(strArr) To UBound(strArr)
    If Asc(strArr(i)) > 58 Then
    strArr(i) = StrReverse(strArr(i))
    End If
    strText = strText & " " & strArr(i)
    Next i
    oCell.Value = Mid(strText, 2)
    Next oCell
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: reverse text (all)

    Thanx Hans work great but I was not clear in request -- I also need the final contents reversed
    ie "edcba 25/75 hgf " should read " fgh 25/75 abcde " and not "abcde 25/75 fgh" as I mistakenly requested
    thanx
    Smbs

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: reverse text (all)

    Change

    For i = LBound(strArr) To UBound(strArr)

    to

    For i = UBound(strArr) To LBound(strArr) Step -1

  5. #5
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: reverse text (all)

    Thanx Hans works great
    Regards
    Smbs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •