I want to change the order of a string such as 32cd4f18 so that it gives an output of 23dcf481. So the string should be swapped in pairs. If someone could help me with a VBA code that would be very helpful.
You did not say if you have just the one text string to process (as your post seems to indicate) or a column's worth of data to process. Here is a UDF (user defined function) that can be used for one or a somewhat small number of text strings (if you have a large list to process, a macro would probably be more efficient)...
VBA Code:
Function ReversePairs(S As String) As String
Dim X As Long
For X = 1 To Len(S) Step 2
ReversePairs = ReversePairs & StrReverse(Mid(S, X, 2))
Next
End Function
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.