Hi iv written a fairly simple spread sheet to manage my accounts as a sole trader. I have included a few macros to print invoices, create invoice files, all work really well.
The problem I'm having seems very simple but I cannot seem to sort it.
I have a separate worksheet for storing receipt data just 4 columns Date, company, amount, Class, as receipts don't always come in in date order, they are inputted as they come in.
I want to be able to sort them by date by running a macro.
As below:
Sub Datesort(I'
'
' Datesort Macro
' Sort all receipts by date
'
' Keyboard Shortcut: Ctrl+d
'
Range("A2:E1000").Select
ActiveWorkbook.Worksheets("Receipts").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Receipts").Sort.SortFields.Add Key:=Range( _
"A3:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Receipts").Sort
.SetRange Range("A2:E1000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
The problem is it sorts the data fine, but as the worksheet has only a few entries at present, it moves the sorted data to the bottom of the sheet and fills the top of the sheet with all the rows of blank cells. How can I persuade it to only sort the cells with data in and ignore the blank cells, or alternatively display with the blank cells at the bottom.
Many thanks.
Bookmarks