zeekmcphee
New Member
- Joined
- Feb 27, 2018
- Messages
- 25
- Office Version
- 2016
- Platform
- Windows
Hello
I am looking for a VBA solution
I have a sheet with several thousand rows.The rows are split up into blocks of rows and seperated by an empty row.Each block of rows will vary with entries so these are random
The sheet has 7 fields author,book_ title,publisher,year_published,genre,number,copies_sold.
The number field is a number against each book title within the block of rows
The last field..copies_sold is a numeric field and what I would like to do is sort each authors copies sold field from least sold to most sold.
If the sheet was one long continuous record then sorting would be easy,but it is a series of blocks of records for each author.
Is there a way that I could some how loop through each individual authors block and sort the copies sold field from smallest to largest;
Below is an example of just three authors,there are three blocks of rows of 4,6and7
[TABLE="width: 100"]
<tbody>[TR]
[TD]author_name.. [/TD]
[TD]book_title..[/TD]
[TD]publisher..[/TD]
[TD]year_published[/TD]
[TD]number[/TD]
[TD]genre[/TD]
[TD]copies_sold[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]swan[/TD]
[TD]dolphin[/TD]
[TD]2014[/TD]
[TD]1[/TD]
[TD]mystery[/TD]
[TD]26000[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]the rock[/TD]
[TD]dolphin[/TD]
[TD]2013[/TD]
[TD]2[/TD]
[TD]mystery[/TD]
[TD]18500[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]daytime[/TD]
[TD]dolphin[/TD]
[TD]2012[/TD]
[TD]3[/TD]
[TD]thriller[/TD]
[TD]670500[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]lost[/TD]
[TD]gracey[/TD]
[TD]2006[/TD]
[TD]4[/TD]
[TD]mystery[/TD]
[TD]78000[/TD]
[/TR]
[TR]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty [/TD]
[TD]empty [/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]sunshine[/TD]
[TD]gracey[/TD]
[TD]2008[/TD]
[TD]1[/TD]
[TD]crime[/TD]
[TD]136000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]rocket[/TD]
[TD]gracey[/TD]
[TD]2006[/TD]
[TD]2[/TD]
[TD]crime[/TD]
[TD]236000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]last one in[/TD]
[TD]gracey[/TD]
[TD]2007[/TD]
[TD]3[/TD]
[TD]mystery[/TD]
[TD]900000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]waterfall[/TD]
[TD]bell[/TD]
[TD]2010[/TD]
[TD]4[/TD]
[TD]mystery[/TD]
[TD]155000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]the ring[/TD]
[TD]bell[/TD]
[TD]2016[/TD]
[TD]5[/TD]
[TD]thriller[/TD]
[TD]257893[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]april[/TD]
[TD]bell[/TD]
[TD]2017[/TD]
[TD]6[/TD]
[TD]thriller[/TD]
[TD]823456[/TD]
[/TR]
[TR]
[TD]empty[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]mrs jones[/TD]
[TD]bell [/TD]
[TD]2017[/TD]
[TD]1[/TD]
[TD]bio[/TD]
[TD]289000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]the parade[/TD]
[TD]gracey[/TD]
[TD]2017[/TD]
[TD]2[/TD]
[TD]bio[/TD]
[TD]456000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]carnival[/TD]
[TD]gracey[/TD]
[TD]2014[/TD]
[TD]3[/TD]
[TD]thriller[/TD]
[TD]234000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]valley[/TD]
[TD]dolphin[/TD]
[TD]2012[/TD]
[TD]4[/TD]
[TD]mystery[/TD]
[TD]980000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]my tree[/TD]
[TD]dolphin[/TD]
[TD]2010[/TD]
[TD]5[/TD]
[TD]romance[/TD]
[TD]345000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]talk[/TD]
[TD]dolphin[/TD]
[TD]2009[/TD]
[TD]6[/TD]
[TD]romance[/TD]
[TD]650000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]smile[/TD]
[TD]bell[/TD]
[TD]2003[/TD]
[TD]7[/TD]
[TD]thriller[/TD]
[TD]345000[/TD]
[/TR]
</tbody>[/TABLE]
Hope this makes sense
ZM
I am looking for a VBA solution
I have a sheet with several thousand rows.The rows are split up into blocks of rows and seperated by an empty row.Each block of rows will vary with entries so these are random
The sheet has 7 fields author,book_ title,publisher,year_published,genre,number,copies_sold.
The number field is a number against each book title within the block of rows
The last field..copies_sold is a numeric field and what I would like to do is sort each authors copies sold field from least sold to most sold.
If the sheet was one long continuous record then sorting would be easy,but it is a series of blocks of records for each author.
Is there a way that I could some how loop through each individual authors block and sort the copies sold field from smallest to largest;
Below is an example of just three authors,there are three blocks of rows of 4,6and7
[TABLE="width: 100"]
<tbody>[TR]
[TD]author_name.. [/TD]
[TD]book_title..[/TD]
[TD]publisher..[/TD]
[TD]year_published[/TD]
[TD]number[/TD]
[TD]genre[/TD]
[TD]copies_sold[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]swan[/TD]
[TD]dolphin[/TD]
[TD]2014[/TD]
[TD]1[/TD]
[TD]mystery[/TD]
[TD]26000[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]the rock[/TD]
[TD]dolphin[/TD]
[TD]2013[/TD]
[TD]2[/TD]
[TD]mystery[/TD]
[TD]18500[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]daytime[/TD]
[TD]dolphin[/TD]
[TD]2012[/TD]
[TD]3[/TD]
[TD]thriller[/TD]
[TD]670500[/TD]
[/TR]
[TR]
[TD]molly brown[/TD]
[TD]lost[/TD]
[TD]gracey[/TD]
[TD]2006[/TD]
[TD]4[/TD]
[TD]mystery[/TD]
[TD]78000[/TD]
[/TR]
[TR]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty [/TD]
[TD]empty [/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]sunshine[/TD]
[TD]gracey[/TD]
[TD]2008[/TD]
[TD]1[/TD]
[TD]crime[/TD]
[TD]136000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]rocket[/TD]
[TD]gracey[/TD]
[TD]2006[/TD]
[TD]2[/TD]
[TD]crime[/TD]
[TD]236000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]last one in[/TD]
[TD]gracey[/TD]
[TD]2007[/TD]
[TD]3[/TD]
[TD]mystery[/TD]
[TD]900000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]waterfall[/TD]
[TD]bell[/TD]
[TD]2010[/TD]
[TD]4[/TD]
[TD]mystery[/TD]
[TD]155000[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]the ring[/TD]
[TD]bell[/TD]
[TD]2016[/TD]
[TD]5[/TD]
[TD]thriller[/TD]
[TD]257893[/TD]
[/TR]
[TR]
[TD]ken davies[/TD]
[TD]april[/TD]
[TD]bell[/TD]
[TD]2017[/TD]
[TD]6[/TD]
[TD]thriller[/TD]
[TD]823456[/TD]
[/TR]
[TR]
[TD]empty[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[TD]empty
[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]mrs jones[/TD]
[TD]bell [/TD]
[TD]2017[/TD]
[TD]1[/TD]
[TD]bio[/TD]
[TD]289000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]the parade[/TD]
[TD]gracey[/TD]
[TD]2017[/TD]
[TD]2[/TD]
[TD]bio[/TD]
[TD]456000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]carnival[/TD]
[TD]gracey[/TD]
[TD]2014[/TD]
[TD]3[/TD]
[TD]thriller[/TD]
[TD]234000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]valley[/TD]
[TD]dolphin[/TD]
[TD]2012[/TD]
[TD]4[/TD]
[TD]mystery[/TD]
[TD]980000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]my tree[/TD]
[TD]dolphin[/TD]
[TD]2010[/TD]
[TD]5[/TD]
[TD]romance[/TD]
[TD]345000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]talk[/TD]
[TD]dolphin[/TD]
[TD]2009[/TD]
[TD]6[/TD]
[TD]romance[/TD]
[TD]650000[/TD]
[/TR]
[TR]
[TD]dawn ellis[/TD]
[TD]smile[/TD]
[TD]bell[/TD]
[TD]2003[/TD]
[TD]7[/TD]
[TD]thriller[/TD]
[TD]345000[/TD]
[/TR]
</tbody>[/TABLE]
Hope this makes sense
ZM