Ramadan2512
New Member
- Joined
- Sep 7, 2024
- Messages
- 40
- Office Version
- 2021
- Platform
- Windows
I have recorded a Macro to re-arrange my table with color and to sort row by date Ascending but later I needed to add 03 rules to remove all filters in the table to show all data then to go to the last row in table and to save the workbook but it seems that they need to be set in a professional way to run smoothly and properly because it gives me an error in this area - so I need a help to do that please
here is my code
here is my code
VBA Code:
[
Sub Rearrange()
Range("B8:K8").Select
Selection.Copy
Range("Table1").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Data").ListObjects("Table1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Data").ListObjects("Table1").Sort.SortFields.Add( _
Range("Table1[[#All],[Column10]]"), xlSortOnCellColor, xlAscending, , _
xlSortNormal).SortOnValue.Color = RGB(146, 208, 80)
With ActiveWorkbook.Worksheets("Data").ListObjects("Table1").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.ShowAllData
ThisWorkbook.Save
Selection.End(xlDown).Select
End Sub
]