Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Insert space before CAPITAL letters

I have some very large files where some columns have the text without any
spaces. However they are using CAPS for all first letters. For example:

TheBookStore
WalmartDiscountStores

Is there a formula or macro that can add a space before every CAP (PROPER)
letter so that it will read:

The Book Store
Walmart Discount Stores

Thanks,
Althea

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Insert space before CAPITAL letters

Try :
Sub test()
Dim c As Range, i As Long, txt As String
For Each c In Range("A1", [A65000].End(xlUp))
txt = ""
For i = 1 To Len(c.Value)
If Mid(c, i, 1) = UCase(Mid(c, i, 1)) Then
txt = txt & " " & Mid(c, i, 1)
Else
txt = txt & Mid(c, i, 1)
End If
Next i
c.Value = Right(txt, Len(txt) - 1)
Next c
End Sub

Regards.
Daniel

I have some very large files where some columns have the text without any
spaces. However they are using CAPS for all first letters. For example:

TheBookStore
WalmartDiscountStores

Is there a formula or macro that can add a space before every CAP (PROPER)
letter so that it will read:

The Book Store
Walmart Discount Stores

Thanks,
Althea



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Insert space before CAPITAL letters

Try code like the following. Select the cells you want to change and
then run the code:

Sub AAA()
Dim R As Range
Dim N As Long
Dim S As String
If TypeOf Selection Is Excel.Range Then
For Each R In Selection.Cells
If R.HasFormula = False Then
If R.HasArray = False Then
S = R.Text
For N = Asc("A") To Asc("Z")
S = Replace(S, Chr(N), " " & Chr(N))
Next N
S = LTrim(S)
R.Value = S
End If
End If
Next R
End If
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Tue, 11 Nov 2008 04:51:01 -0800, althea@ads-ny
wrote:

I have some very large files where some columns have the text without any
spaces. However they are using CAPS for all first letters. For example:

TheBookStore
WalmartDiscountStores

Is there a formula or macro that can add a space before every CAP (PROPER)
letter so that it will read:

The Book Store
Walmart Discount Stores

Thanks,
Althea

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Insert space before CAPITAL letters

Chip,

You are a God-send!! Worked like a charm. I have thousands of lines in
many files and many columns and this will save me hours!!!

Thanks again!
Althea

"Chip Pearson" wrote:

Try code like the following. Select the cells you want to change and
then run the code:

Sub AAA()
Dim R As Range
Dim N As Long
Dim S As String
If TypeOf Selection Is Excel.Range Then
For Each R In Selection.Cells
If R.HasFormula = False Then
If R.HasArray = False Then
S = R.Text
For N = Asc("A") To Asc("Z")
S = Replace(S, Chr(N), " " & Chr(N))
Next N
S = LTrim(S)
R.Value = S
End If
End If
Next R
End If
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Tue, 11 Nov 2008 04:51:01 -0800, althea@ads-ny
wrote:

I have some very large files where some columns have the text without any
spaces. However they are using CAPS for all first letters. For example:

TheBookStore
WalmartDiscountStores

Is there a formula or macro that can add a space before every CAP (PROPER)
letter so that it will read:

The Book Store
Walmart Discount Stores

Thanks,
Althea


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change small letters to capital letters HOW TO CHANGE Excel Discussion (Misc queries) 4 May 30th 07 01:12 AM
how do i turn all letters into capital letters? KeithT Excel Discussion (Misc queries) 3 May 11th 07 02:13 PM
Capital Letters Only Simon Jefford Excel Discussion (Misc queries) 2 February 2nd 06 06:04 PM
Capital Letters teresa Excel Programming 23 March 24th 05 03:17 PM
Capital Letters Gaute Excel Worksheet Functions 4 March 9th 05 09:55 AM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"