instanceoftime
Board Regular
- Joined
- Mar 23, 2011
- Messages
- 103
I'm using the code below to format spreadsheets with various number of rows.
Unfortunately I have noticed my "sort" portion isn't always working correctly?
end result:
Unfortunately I have noticed my "sort" portion isn't always working correctly?
end result:
1999.99 |
1699.99 |
599.99 |
249.99 |
449.99 |
449.99 |
399.99 |
199.99 |
119.99 |
349.99 |
349.99 |
169.99 |
329.99 |
299.99 |
299.99 |
299.99 |
299.99 |
129.99 |
249.99 |
49.99 |
239.99 |
VBA Code:
Sub invoice()
'
' formating Macro
' control u
'
' Keyboard Shortcut: Ctrl+u
'
Cells.Select 'left align
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("C:C,D:D,H:M").Select 'delete some columns
Range("H1").Activate
Selection.delete Shift:=xlToLeft
Columns("C:C").Select 'resize column
Selection.ColumnWidth = 45
[COLOR=rgb(226, 80, 65)] Range("A2", Range("E" & Rows.Count).End(xlUp)).Sort [A2], xlDescending 'sort by column E[/COLOR]
With Range("A2", Range("A" & Rows.Count).End(xlUp)) 'truncate number in A
.Value = Evaluate(Replace("If(@="""","""",right(@,3))", "@", .Address))
End With
End Sub