Split String at occurrence of Uppercase

Blessy Clara

Board Regular
Joined
Mar 28, 2010
Messages
204
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a column of address - with the City in Upper case, I would like to split the string at the occurrence of Uppercase from right

Example - Uppercase i have highlighted as Red here

[TABLE="width: 500"]
<tbody>[TR]
[TD]Unit 12, Wellington Fair 40 Lord Street (Entrance off Wellington Street) EAST PERTH[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Building 3, Level B, Suites B53-B56 1 Kirinari Street BRUCE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Level 3 106 Edward Street BRISBANE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Post Split[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Unit 12, Wellington Fair 40 Lord Street (Entrance off Wellington Street) [/TD]
[TD]EAST PERTH[/TD]
[/TR]
[TR]
[TD]Building 3, Level B, Suites B53-B56 1 Kirinari Street [/TD]
[TD]BRUCE[/TD]
[/TR]
</tbody>[/TABLE]

Thank you
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello,

try this code

Code:
for i = 1 to cells(rows.count,1) 'all cells in column A
    for k = 1 to len(cells(i,1) -2 'loop all characters
        if mid(cells(i,1),k,2) like "[A-ZA-Z]" then cells(i,2) = left(cells(i,1),k)
    next k
next i

(untested)

regards
 
Last edited:
Upvote 0
Hi Fennek,

Thank you for the code - Please i need some guidance to go about , I am getting compile error - Invalid outside procedure?
 
Upvote 0
do you need this?

Code:
'NO option explicit
sub iFen()
for i = 1 to cells(rows.count,1) 'all cells in column A
    for k = 1 to len(cells(i,1) -2 'loop all characters
        if mid(cells(i,1),k,2) like "[A-ZA-Z]" then cells(i,2) = left(cells(i,1),k)
    next k
next i
end sub
 
Upvote 0
Hi Fennek,

Thank you for the suggestion, i tried , not getting an error this time but nothing happening, the cols are not split.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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