How do we separate text by upper / lower case

mohammad_t

New Member
Joined
Nov 19, 2013
Messages
2
Hello everyone,

I have a long list of company names. Each company's name has got combined like "AstroPhysics" instead of "Astro Physics".

Can anyone help me how to separate combined text by reference to where a letter appears in upper / lower case?

Thanks & Regards,
Talha
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This CSE will return the last bit of text that is begun with a capital

=MID(A1,MATCH(TRUE,EXACT(LOWER(MID(A1,COLUMN(A:IU),255)), MID(A1,COLUMN(A:IU),255)),0)-1,255-1)

Enter this with Ctrl-Shift-Enter (Cmd+Return for Mac)
 
Upvote 0
Hello everyone,

I have a long list of company names. Each company's name has got combined like "AstroPhysics" instead of "Astro Physics".

Can anyone help me how to separate combined text by reference to where a letter appears in upper / lower case?

Assuming you want to physically change the original data within their cells, give the following macro a try. Note... you did not tell us the column your company names were in, so I assumed Column A... if that guess was not correct, then change the "A" in the highlighted code line to the actual letter designation for the column containing your company names.

Rich (BB code):
Sub AddSeparatingSpacesToNames()
  Dim R As Long, C As Long, Arr As Variant
  Const NameCol As String = "A"
  Arr = Range(Cells(1, NameCol), Cells(Rows.Count, NameCol).End(xlUp))
  For R = 1 To UBound(Arr)
    For C = Len(Arr(R, 1)) To 2 Step -1
      If Mid(Arr(R, 1), C, 2) Like "[a-z][A-Z]" Then
        Arr(R, 1) = Application.Replace(Arr(R, 1), C + 1, 0, " ")
      End If
    Next
  Next
  Cells(1, NameCol).Resize(UBound(Arr)) = Arr
End Sub
 
Upvote 0
Thanks mikerickson, Rick and Armando. I guess I'm too new to Excel to apply your suggestions :).
For the code I posted in Message #3....

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (AddSeparatingSpacesToNames) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm).

NOTE: Make sure to read the part where I describe what to do with the red highlighted text in Message #3.
 
Upvote 0
My formula was an Excel CSE formula
If your string is in A1, use the formula as written, if not change the A1's in the formula to match your situation but leave the A:UI reference alone.

put the formula in a cell, but press Ctrl-Shift-Enter simultaneously to enter the formula, rather then only Enter.
 
Upvote 0
This CSE will return the last bit of text that is begun with a capital

=MID(A1,MATCH(TRUE,EXACT(LOWER(MID(A1,COLUMN(A:IU),255)), MID(A1,COLUMN(A:IU),255)),0)-1,255-1)

Enter this with Ctrl-Shift-Enter (Cmd+Return for Mac)
If it is a text with capital letters, how: "mao GT100 anh" separates GT100
 
Upvote 0
This thread is nearly 10 years old - you will get better help if you start a new thread.
 
Upvote 0

Forum statistics

Threads
1,220,441
Messages
6,153,921
Members
451,178
Latest member
elbayomy66

We've detected that you are using an adblocker.

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.
Go back
Back
Top