Macro to separate records and convert one row into multiple columns

Des888

New Member
Joined
Mar 1, 2012
Messages
7
Hi, Can you please help?, I need a macro for excel 2007
I have a spreadsheet that has only one row and about 850 columns containing names job titles and a further 9 columns of details)

I need to convert this:
name_1 jobtitle_1 email_1 phonenumber_1 fax_1 example _1 name_2 etc


to this:
one column for names one column for job titles one column for emails etc

Hope this makes sense. Thank you!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Yes every column in this order,
It is:
Name/Qualification(sometimes blank)/JobTitle1/JobTitleLine2 (sometimes blank)/Direct Line(text)/Direct Line(number)/email/emaildomain/Fax(text)/Fax (number)/blank field

Thank you!
 
Upvote 0
So each record is made up of 11 columns?

i.e
record1 uses cols a:k
record2 uses cols l:v
etc
 
Upvote 0
Something along the lines of

Range("a1").Select

lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
Dim c As Range, rng
Dim LASTROW As Long


numRows = Selection.Rows.Count
numColumns = Selection.Columns.Count
Selection.Resize(numRows + 0, numColumns + lastcol - 1).Select

For Each c In Selection
If c.Column Mod 11 = 0 Then
c.Offset(0, 1).Select
Selection.Resize(1, 11).Select
Selection.Copy
LASTROW = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(LASTROW, 1).Select
ActiveSheet.Paste
End If
Next c
 
Upvote 0
If there is a / between every item you want in a column all you have to do is goto data > text to colums > then in step two check the other box and type in a /

TextToColumns.jpg
 
Upvote 0
There are no / between items I was denoting the different columns, sorry for any confusion.

Many thanks for your effort on this Steve too but I was unable to make it work, I received an error in a window

"Compile error:
Invalid outside procedure"

and the "a1" at the beginning of the script was highlighted.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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