Hi there,
I have this spreadsheet containing over 7000 x contacts. Each contact consists of up to 38 values (to include first name, surname, title, address etc.). For some reason the first 15 values are displayed horizontally, and beneath, the remaining 23 values are listed vertically. How do I convert the 23 values into a horizontal display? See attached example - 3 x contacts are provided in this example:
tab 1 'existing' - contains the existing layout
tab 2 'EndResult' - is what I want to achieve
There are many merged cells in tab 1 and some shifting required to ensure there are no blank cells.
Could anyone help?
Much appreciated.
Helena
Run this macro on your data, as long as it is exactly in the layout shown:
Option Explicit Sub ReformatData() Dim RNG As Range, r As Long Application.ScreenUpdating = False Set RNG = Range("A:A").SpecialCells(xlConstants) For r = 1 To RNG.Areas.Count Range("B" & RNG.Areas(r).Cells(1).Row).Resize(6).Copy Range("U" & RNG.Areas(r).Cells(1).Row - 1).PasteSpecial xlPasteValues, Transpose:=True Range("D" & RNG.Areas(r).Cells(1).Row).Resize(7).Copy Range("AA" & RNG.Areas(r).Cells(1).Row - 1).PasteSpecial xlPasteValues, Transpose:=True Range("F" & RNG.Areas(r).Cells(1).Row).Resize(10).Copy Range("AH" & RNG.Areas(r).Cells(1).Row - 1).PasteSpecial xlPasteValues, Transpose:=True Next r Range("G:G").SpecialCells(xlBlanks).EntireRow.Delete xlShiftUp Range("A:E").Delete xlShiftToLeft Rows(1).Insert xlShiftDown For r = 1 To 38 Cells(1, r) = "Title " & r Next r Range("A1").Select Application.ScreenUpdating = True End Sub
How/Where to install the macro:
1. Open up your workbook
2. Get into VB Editor (Press Alt+F11)
3. Insert a new module (Insert > Module)
4. Copy and Paste in your code (given above)
5. Get out of VBA (Press Alt+Q)
6. Save as a macro-enabled workbook (.xlsm)
The macro is installed and ready to use. Press Alt-F8 and select ReformatData from the macro list.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Hi tiggi and JB
This is just a test as the thread has zero replies but observably JB has posted??
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
VBA for smarties - snb
Wow, this site is amazing! Thanks for the efforts and prompt response JB! And appreciate the follow up check Pike!
JB, I installed your macro, saved the spreadsheet in the xlsm format, then ran it but I received a runtime error '1004': "No cells found". When I ran it, the cursor was sitting in a new empty sheet in cell a1. Got any further advice?
Much appreciate your time.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks