Skip Bisconer
Active Member
- Joined
- Jun 14, 2002
- Messages
- 263
It's been quite a while since I have created VBA and now using the latest Excel in Office 365 I am stumbling over something that should be easy. I recorded the following code using record macro but doesn't come out the way I want it. I download a .cvs from my investment account and need to reformat and and arrange before I copy it over to my working data sheets. I have everything working except selecting the entire range of data and sorting in ascending order. The recorded macro gives me the fixed range of data and I need it to be variable as each download .cvs has more or less data. The following is what I get with the recorded macro.
I need the range to be A4: to end of data. It's the end of data that I haven't been able to locate.
Thanks for assistance you can give me.
Code:
Range("A4").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveWorkbook.Worksheets("AccountHistoryReport").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("AccountHistoryReport").Sort.SortFields.Add Key:= _
Range("A4:A14"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("AccountHistoryReport").Sort
.SetRange Range("A4:V14")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Thanks for assistance you can give me.