![]() |
Rearranging columns/rows
I have a spreadsheet of the form
NAME BOOK1 BOOK2 BOOK3... Bob aaa bbbb cccc Jill ddd eee Fred fff Jack ggg hhhh which I want to reformat into the form NAME BOOK Bob aaa Bob bbb Bob ccc Jill ddd Jill eee Fred fff etc Can anybody suggest the best way to do this? The no. of BOOKx columns will vary, and because the spreadsheet will be a regular one, I'll need a macro or such to automate the process TIA BernieH |
Rearranging columns/rows
Sub Test()
Dim iLastRow As Long Dim i As Long, j As Long iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 2 Step -1 For j = 3 To Cells(i, Columns.Count).End(xlToLeft).Column Rows(i + 1).Insert Cells(i + 1, "A").Value = Cells(i, "A").Value Cells(i + 1, "B").Value = Cells(i, j).Value Cells(i, j).Value = "" Next j Next i End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "BernieH" wrote in message ... I have a spreadsheet of the form NAME BOOK1 BOOK2 BOOK3... Bob aaa bbbb cccc Jill ddd eee Fred fff Jack ggg hhhh which I want to reformat into the form NAME BOOK Bob aaa Bob bbb Bob ccc Jill ddd Jill eee Fred fff etc Can anybody suggest the best way to do this? The no. of BOOKx columns will vary, and because the spreadsheet will be a regular one, I'll need a macro or such to automate the process TIA BernieH |
All times are GMT +1. The time now is 08:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com