ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Spacing Macro (https://www.excelbanter.com/excel-programming/334301-spacing-macro.html)

Silent

Spacing Macro
 
Hi,
Im looking for a spacing macro that adds spaces based on Capitalization
changes. For example if I have : JhonDoeDeer, the macro will move it to
another cell as John Doe Deer. If anyone knows of a website that shows a
template for a macro like this, please let me know. Or if there is some way
to do this with clever excel equations, that would be great too. Thanks
again.

STEVE BELL

Spacing Macro
 
This worked for me in Excel 2000

Dim str As String, n As Integer, str2 As String
str = "AbCdE"
str2 = Left(str, 1)
For n = 2 To Len(str)
If Mid(str, n, 1) = UCase(Mid(str, n, 1)) Then
str2 = str2 & " " & Mid(str, n, 1)
Else: str2 = str2 & Mid(str, n, 1)
End If
Next
MsgBox str2


--
steveB

Remove "AYN" from email to respond
"Silent" wrote in message
...
Hi,
Im looking for a spacing macro that adds spaces based on Capitalization
changes. For example if I have : JhonDoeDeer, the macro will move it to
another cell as John Doe Deer. If anyone knows of a website that shows a
template for a macro like this, please let me know. Or if there is some
way
to do this with clever excel equations, that would be great too. Thanks
again.





All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com