Address Rows to Columns dependent upon a Cell Value of Account Ref - hard to explain!

MattDanFrank2

New Member
Joined
Sep 19, 2012
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm really hoping someone can help me please.

I've extracted approx 9000 rows of data from a paper document using some OCR software, which I now need to get into a format that I can put into a database i.e. account, address line 1, address line 2, address line 3 etc.

As you can see in the main table at the bottom, in column A there is the account number with the corresponding address info in multiple rows in column B.

Is there a way to separate the address rows in column B to multiple columns instead, in the same row as the Account Ref?

Note: Not all the addresses have the same number of rows

For example,


ABCDEF
1ACCOUNTADD1ADD2ADD3ADD4ADD5
2321321 Recreation ClubGilmore StreetAlexandriaGlasgowG83 0DA

<colgroup><col><col></colgroup><tbody>
</tbody>

Your help will be so much appreciated!!

Matthew

Main Table

AB
1ACCOUNTTO SEPARATE
2321321 Recreation Club
3 Gilmore Street
4 Alexandria
5 Glasgow
6 G83 ODA
739STEPS39 Steps
8 28a Great King Street
9 Edinburgh
10 EH3 6Q1-1
114SIGHT4Sight Financial Software Ltd
12 Conference House
13 152 Morrison Street
14 Edinburgh
15 EH3 8EB
16ABALMOURAlan Balmour
17 257 Sandpiper Drive
18 Greenhill
19 East Kilbride
20 G75 8UN

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try this:-
Results sheet(2) starting "A1"
Code:
[COLOR="Navy"]Sub[/COLOR] MG19Sep50
[COLOR="Navy"]Dim[/COLOR] Rng         [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dn          [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Rw          [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] c           [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] oMax        [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 10)
MsgBox Rng.Address
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Dn.Offset(, -1) <> "" Then: Rw = Rw + 1: c = 0
    c = c + 1
        [COLOR="Navy"]If[/COLOR] c = 1 [COLOR="Navy"]Then[/COLOR]
            ray(Rw, c) = Dn.Offset(, -1)
            c = c + 1
            ray(Rw, c) = Dn
        [COLOR="Navy"]Else[/COLOR]
            ray(Rw, c) = Dn
        [COLOR="Navy"]End[/COLOR] If
        oMax = application.Max(oMax, c)
        
[COLOR="Navy"]Next[/COLOR] Dn
Sheets("sheet2").Range("A1").Resize(Rw, oMax) = ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Mick! Whoever and wherever you are - YOU ARE A GOD!!!! I can't thank you enough, seriously, thank you so so much. (running around the office high-fiving people). Best, Matthew.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,632
Members
449,241
Latest member
NoniJ

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