Hey all,
I'm new to VBA and I'm struggling with a problem. I would like to use a (form) command button to run a macro to sort a table by it's date.
However, I've got the following code:
Where I would like to change ListObjects("Tabel15") to a variable I can use over multiple sheets.
For example, selecting the table by fixed cells, instead of a table name.
Date rows: B14 to B50, not including headline
Full table: B14 to H50, not including headline
Sorry, it's been a long day and I've been struggling with this for a while. Most likely my code as well as my post is pretty messy, but I would be more than pleased to clearify things up!
I'm new to VBA and I'm struggling with a problem. I would like to use a (form) command button to run a macro to sort a table by it's date.
However, I've got the following code:
VBA Code:
ActiveWorkbook.ActiveSheet.ListObjects("Tabel15").Sort.SortFields. _
For example, selecting the table by fixed cells, instead of a table name.
VBA Code:
Sub FilterNieuwOud()
'
' FilterNieuwOud Macro
'
'
Range("B14").Select
ActiveWorkbook.ActiveSheet.ListObjects("Tabel15").Sort.SortFields. _
Clear
ActiveWorkbook.ActiveSheet.ListObjects("Tabel15").Sort.SortFields. _
Add2 Key:=Range("Tabel15[Datum]"), SortOn:=xlSortOnValues, Order:= _
xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.ListObjects("Tabel15").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Date rows: B14 to B50, not including headline
Full table: B14 to H50, not including headline
Sorry, it's been a long day and I've been struggling with this for a while. Most likely my code as well as my post is pretty messy, but I would be more than pleased to clearify things up!
Last edited by a moderator: