1

I have Excel data file. in cells I have data like this

480000074B26E42D

How can I Get result in other cell Like this

2DE4264B07000048

So, I want to take the last 2 digits and put them to front. Then the next 2 digits before the 2D and put it after the 2D(the one in front)

enter image description here

I try to use this code but I get wrong result

=RIGHT(B2,LEN(B2) -2)
akaco
  • 663
  • 3
  • 11
  • 27
  • 1
    http://stackoverflow.com/q/350264/293078 – Doug Glancy Jul 27 '13 at 03:53
  • It looks like a hexadecimal value and you want to reverse the order of the bytes, yes? At least ignoring a little dyslexia on the `48`/`84` end of the string. – HABO Jul 27 '13 at 17:24

3 Answers3

7

I believe the other contributors have misunderstood your requirements & are simply offering advice to reverse the value provided.

With the input of 480000074B26E42D, I think your required outcome is incorrect: 2DE4264B07000084. The last two characters have been transposed, & the actual output will be:
2DE4264B07000048.

If that is correct, you may use this Visual Basic for Applications function (stored in a Public code module)


Public Function strReverse_Character_Pairs(ByVal strValue As String) As String

  Dim lngLoop                                           As Long
  Dim strReturn                                         As String

  strReturn = ""

  For lngLoop = Len(strValue) - 1& To 1& Step -2&
      strReturn = strReturn & Mid$(strValue, lngLoop, 2)
  Next lngLoop

  strReverse_Character_Pairs = strReturn  
End Function

Usage, based on the original text in cell A1, would be as follows (with this formula placed in any cell other than cell A1):

=strReverse_Character_Pairs(A1)

The function could also be enhanced to check that the value has an even number of characters by adding a "dummy" character at either end so that the reversed pairs are as intended.

brettdj
  • 54,857
  • 16
  • 114
  • 177
fanpages
  • 126
  • 1
  • 2
-1

I think a little vba may be the the answer, I just tested this and it works fine

brettdj
  • 54,857
  • 16
  • 114
  • 177
MikeAinOz
  • 126
  • 1
  • 10
  • 24
  • 1
    From the [SO help pages](http://stackoverflow.com/help/how-to-answer) - "Provide context for links - Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline." – barrowc Jul 28 '13 at 00:25
  • it doesnt answer the question. its not what the op asked for. this reverses the string and the OP wants the string reversed in pairs of two! –  Oct 03 '13 at 12:18
-1

Use the following function in VBA:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cells(3, 1) = StrReverse(Cells(1, 1))    
End Sub

Where Cell A1 contains the string to be flipped. Cell A3 contains the result

brettdj
  • 54,857
  • 16
  • 114
  • 177
rangan
  • 1
  • it doesnt answer the question. its not what the op asked for. this reverses the string and the OP wants the string reversed in pairs of two! –  Oct 03 '13 at 12:19