Hi,
I'm fairly new to macros and the like in excel so bare with me.
I have a sheet which I am using to track spending and have a macro/Active X button to sort the data at the end. The trouble is that as I have added new rows they are not included in the range and have to change that each time. Is there a way to get the macro to check the range by looking for the cells that have data in a specific column, say the date column?
Basically the macro selects the rows and columns with data in and then sorts it by the date range descending.
Heres the macro code
Any help would be greatly appreciated![]()
Private Sub CommandButton1_Click() ' ' Kitpartsspending Macro ' ' Range("B3:F33").Select ActiveWorkbook.Worksheets("Kitparts Spending").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Kitparts Spending").Sort.SortFields.Add Key:=Range _ ("B3:B33"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal With ActiveWorkbook.Worksheets("Kitparts Spending").Sort .SetRange Range("B2:F33") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With ActiveWindow.SmallScroll Down:=15 Range("E35").Select End Sub
Thanks in advance
Bookmarks