Im taking one of those free continuing education courses to maintain my designation...anyway, one of the tasks is to make a loop that reverse the string in Excel, but im totally lost...could someone help me, pleasE?
I have a custom function set up to do this, but you should be able to modify it into a macro if needed:
Code:
Function REVERSESTRING(c) As String
Dim i As Integer
For i = Len(c) To 1 Step -1
my_string = my_string & Mid(c, i, 1)
Next i
REVERSESTRING = my_string
End Function
This would change "Adam Zapple" into "elppaZ madA"
I was playing with this as it interested me, thought i would paste what i had anyway.
Code:
Sub SrtRev()
Dim x As Long, str As String, var() As Variant
str = "ABCDEFG" 'define string
For x = 1 To Len(str)
ReDim Preserve var(x)
var(x) = Mid(str, x, 1)
Next
For x = LBound(var) To UBound(var) / 2
tmp = var(UBound(var) - x)
var(UBound(var) - x) = var(x)
var(x) = tmp
Next x
For x = LBound(var) To UBound(var) - 1
MsgBox var(x)
Next x
End Sub
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.