split and join data case sensitive

already

Board Regular
Joined
Nov 11, 2008
Messages
179
Hi

I have a large data base with 8 columns (imported from the web)
The data consists of names in uppercase and titles in propercase.
The name could be in 1,2 or 3 columns and also the titels coud be spread in more columns.

The goal is to join the uppercase words in one cell and the propercase words in another.

ex 4 columns

1/ LENNY |KRAVITZ |Black And White |America

ex 3 columns
2/ THE KOOKS | Junk Of The | Heart

should be converted in

1/ LENNY KRAVITZ | Black And White America
2/ THE KOOKS | Junk Of The Heart

etc

Thanks in advance for your help

Kind regards

Al
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
This macro will create your items in columns J:K

Code:
Option Explicit
Option Compare Binary   'case sensitive

Sub Reformat()
Dim LR As Long, rw As Long, BUF As String, buf2 As String
Dim RNG As Range, NmStr As Range

LR = Range("A" & Rows.Count).End(xlUp).Row
Range("J:K").ClearContents

For rw = 2 To LR
    Set RNG = Rows(rw).SpecialCells(xlConstants)
    For Each NmStr In RNG
        If NmStr = UCase(NmStr) Then
            BUF = BUF & " " & NmStr
        Else
            buf2 = buf2 & " " & NmStr
        End If
    Next NmStr
    Range("J" & rw) = Trim(BUF)
    Range("K" & rw) = Trim(buf2)
    BUF = ""
    buf2 = ""
Next rw
            
Range("J:K").Columns.AutoFit
End Sub

Excel Workbook
ABCDEFGHIJK
1
2LENNYKRAVITZBlack And WhiteAmericaLENNY KRAVITZBlack And White America
3THE KOOKSJunk Of TheHeartTHE KOOKSJunk Of The Heart
4BOBJOHNDILLONOnly InAmericaBOB JOHN DILLONOnly In America
5
6
Blad2
 
Last edited:
Upvote 0
Here is another macro for you to consider...

Code:
Sub CombineAllUpperCaseAndAllProperCase()
  Dim X As Long, Z As Long, LastCol As Long, Cell As Range, Upper As String, Proper As String
  Const StartRow As Long = 2
  Const FirstOuputColumn As String = "G"
  For X = StartRow To Cells(Rows.Count, "A").End(xlUp).Row
    LastCol = Cells(X, Columns.Count).End(xlToLeft).Column
    Upper = ""
    Proper = ""
    For Z = 1 To LastCol
      If Not Cells(X, Z).Value Like "*[!A-Z ]*" Then
        Upper = Upper & Cells(X, Z) & " "
      Else
        Proper = Proper & Cells(X, Z) & " "
      End If
    Next
    Cells(X, FirstOuputColumn).Value = Trim(Upper)
    Cells(X, FirstOuputColumn).Offset(, 1).Value = Trim(Proper)
  Next
End Sub
 
Upvote 0
=trim(rept(exact(proper(a1),a1),a1)&" "&rept(exact(proper(b1),b1),b1)&" "&rept(exact(proper(C1),C1),C1)&" "&rept(exact(proper(d1),d1),d1))
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,539
Latest member
alex78

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