I have taken a different approach to producing the report I want. I now want to
1. find either the last cell not containing data
or the first cell containg data so that I can delete all the empty rows and then
2. having done that, find the last cell containg data so that I can highlight all the rows containg data and set the print area, all in the one macro (although I might make the print are/print part a separate macro.
Below is a bit of the worksheet produced by my macro so far (I don't expect you to do all my work for me, just a suggestion as to where I could insert the lines relating to finding the first empty cell and last occupied cell would be a great help):
4382 | | | | | | | | |
4383 | | | | | | | | |
4384 | | | | | | | | |
4385 | | | | | | | | |
4386 | | | | | | | | |
4387 | 4 Instants | Discotheque | LP | $8.00 | $18.00 | 1/11/2013 | $15.00 | $20.00 |
4388 | 4 Instants | Discotheque (2nd copy) | LP | $8.00 | $18.00 | 5/11/2013 | $18.00 | $18.00 |
4389 | aaaaaaaaaaaaa | bbbbbbbbbbbbbbbb | cd | $1.00 | $1.00 | 3/06/2015 | $1.00 | $100.00 |
4390 | Alan Dale & Houserockers | Crackin' Up | LP | $8.00 | $18.00 | 31/07/2014 | $16.00 | $16.00 |
4391 | Alan Freed | And This Is Rock'n'Roll | LP | $8.00 | $19.00 | 15/02/2015 | $15.00 | $15.00 |
4392 | Alan Price | O Lucky Man | CD | $4.00 | $8.00 | 25/03/2012 | $10.00 | $10.00 |
4393 | Allusions | Anthology 1966-1968 | CD | $4.00 | $8.00 | 1/03/2015 | $20.00 | $20.00 |
<colgroup><col><col><col><col><col><col><col><col span="2"></colgroup><tbody>
</tbody>
The macro to do this is:
Sub Process_Sold()
'
' Process_Sold Macro
'
'
Workbooks.Open Filename:="D:\EBAY\EBAY SALES.xlsm", UpdateLinks:=0
Sheets("WORK").Select
Selection.Copy
Sheets("WORK2").Select
Cells.Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("WORK2").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("WORK2").Sort.SortFields.Add Key:=Range("A2:A4999") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("WORK2").Sort.SortFields.Add Key:=Range("B2:B4999") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("WORK2").Sort.SortFields.Add Key:=Range("F2:F4999") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("WORK2").Sort
.SetRange Range("A1:J4999")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
End Sub