Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
BernieH
 
Posts: n/a
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I hide or unhide zero value columns/rows USING A MACRO? paul Excel Discussion (Misc queries) 1 January 23rd 06 03:06 PM
How do I open or close grouped columns/rows in a protected excel s Haranath Excel Discussion (Misc queries) 2 December 18th 05 03:04 PM
Rearranging aTable PT New Users to Excel 2 December 5th 05 05:34 PM
columns/rows teddkilroy New Users to Excel 2 November 14th 05 07:29 PM
Grouped Columns/Rows bayhe Excel Worksheet Functions 2 December 15th 04 12:05 PM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"