# separate,reverse,regroup

#### only_lonely

##### Board Regular
given a hex strings 57 31 7c 4d 30 30 30 30 30 31 35 36 33 7c 7c 54 45 53 54 4c
1. separate into 4 bytes per group
57 31 7c 4d
30 30 30 30
30 31 35 36
33 7c 7c 54
45 53 54 4c

2. reverse it from MSB to LSB way
57 31 7c 4d = 4d 7c 31 57
30 30 30 30 = 30 30 30 30
30 31 35 36 = 36 35 31 30
33 7c 7c 54 = 54 7c 7c 33
45 53 54 4c = 4c 54 53 45

3. regroup
4d 7c 31 57 30 30 30 30 36 35 31 30 54 7c 7c 33 4c 54 53 45

#### Weaver

##### Well-known Member
PS you could incorporate grpLen as an argument

Code:
``````Option Base 0
Function separateReverseRegroup(ByVal strHex As String, grpLen As Integer) As String
Dim spl As Variant, grpCount As Integer
spl = Split(Trim(strHex), " ")
grpCount = Int(UBound(spl) / grpLen) + 1
If (UBound(spl) + 1) Mod grpLen <> 0 Then
separateReverseRegroup = "Not in groups of " & grpLen
Else
For i = 0 To grpCount - 1
For j = grpLen - 1 To 0 Step -1
separateReverseRegroup = separateReverseRegroup & spl(i * grpLen + j) & " "
Next j
Next i
separateReverseRegroup = Trim(separateReverseRegroup)
End If
End Function``````
So you'd call the function with

=separateReverseRegroup(A2,4)

### Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

#### only_lonely

##### Board Regular
cool...i'll learn them. i got lots of works involving data conversion

Replies
3
Views
36
Replies
7
Views
41
Replies
5
Views
40
Replies
0
Views
34
Replies
1
Views
36