Splitting lower case from uppercase

UZZY123

New Member
Joined
Nov 9, 2020
Messages
8
Office Version
  1. 2007
Platform
  1. Windows
harinsh,


Sample raw data:


Excel Workbook
AB
1Bank of Ghana ACCRA
2Bank of Ghana AGONA SWEDRU
3Bank of Ghana TAKORADI
4Bank of Ghana SEFWI BOAKO
5Barclays Bank UNDP
6Barclays Bank TWIFO PRASO
7Barclays Bank WA
8Rural & Community Banks AFRAM RURAL BANK LTD-TEASE
9Ecobank ACCRA SHOPPING MALL
10Amalgamated Bank SPINTEX ROAD
11Fidelity Bank OKAISHIE
12
Sheet1





After the macro:


Excel Workbook
AB
1Bank of GhanaAccra
2Bank of GhanaAgona Swedru
3Bank of GhanaTakoradi
4Bank of GhanaSefwi Boako
5Barclays BankUndp
6Barclays BankTwifo Praso
7Barclays BankWa
8Rural & Community BanksAfram Rural Bank Ltd-Tease
9EcobankAccra Shopping Mall
10Amalgamated BankSpintex Road
11Fidelity BankOkaishie
12
Sheet1





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Code:
Option Explicit
Sub MakeProperV2()
' hiker95, 03/05/2012
' http://www.mrexcel.com/forum/showthread.php?t=618547
Dim c As Range, Sp, s As Long, n As Long, t() As Variant
For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp))
  c = Trim(c)
  Sp = Split(c, " ")
  n = 0
  For s = LBound(Sp) To UBound(Sp)
    If Asc(Right(Sp(s), 1)) > 64 And Asc(Right(Sp(s), 1)) < 91 Then
      Sp(s) = Application.Proper(Sp(s))
      n = n + 1
      ReDim Preserve t(1 To n)
      t(n) = Sp(s)
      Sp(s) = ""
    End If
  Next s
  c = Join(Sp, " ")
  c = Trim(c)
  If n = 1 Then
    c.Offset(, 1).Value = t
  Else
    c.Offset(, 1).Value = Join(t, " ")
  End If
  Erase t
Next c
End Sub


Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


Then run the MakeProperV2 macro.

Hi

I am looking for a macro like the above but the issue i have with this is that in mine i have numbers at the end which i also want including into the next coloum.
I have uploaded images of what i want and what the current macro does to make it easier for you to understand of what i need

Thank you for your help
 

Attachments

  • Current Macro results.jpg
    Current Macro results.jpg
    39.3 KB · Views: 10
  • Intended Result.jpg
    Intended Result.jpg
    25.2 KB · Views: 11
  • Orginal data.jpg
    Orginal data.jpg
    37.8 KB · Views: 10
I Install the add in but i cant see the mrexcel or capture range.
I am using excel 2007, not sure if that maybe the issue
Excel 2007 is OK. Do you see a MrExcel tab on the ribbon? If not, you haven't installed XL2BB correctly.
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
This seems to work with more than one color descriptor.

VBA Code:
Sub t3()
Dim c As Range, spl As Variant, i As Long
    With ActiveSheet
        For Each c In Range("A1", .Cells(Rows.Count, 1).End(xlUp))
            spl = Split(c.Value, " ")
            For i = LBound(spl) To UBound(spl)
                    If Len(spl(i)) > 1 And UCase(spl(i)) = spl(i) Then
                        c.Offset(, 1) = Mid(c.Value, InStr(c.Value, spl(i)))
                        Exit For
                    End If
            Next
        Next
    End With
End Sub

TestBase.xlsm
ABCD
1fjkd sldk fjsle fjkls RED 2RED 2
2fjsld kglsdk ejrkl PEA GREEN 12PEA GREEN 12
3fjei slei ieng oekd BLUE 8BLUE 8
4fjkgl dkek diels FIRE ENGINE RED 12FIRE ENGINE RED 12
5
6
Sheet1
 
Upvote 0

Forum statistics

Threads
1,215,841
Messages
6,127,221
Members
449,371
Latest member
strawberrish

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