You need to have a priority list in the form of an array and then put it into an automatic list as input in a custom sorting (alternatively, get the values in a range as priority list or write them directly as comma delimited). Let's say you want to sort by country size Germany, France, Italy,... would be like this: Dim PrioList As Variant PrioList = Array("Germany", "France", "Italy", "Spain", "Poland") Application.AddCustomList ListArray:=PrioList Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, _ Header:=xlYes, OrderCustom:=Application.CustomListCount + 1 Application.DeleteCustomList Application.CustomListCount
@@VijaySingh-sm5vo You need to use that code before merging the cells, with the original table, just like in the video, first sort, then merge. Good luck!
Perfect! This deserved more views.
Nice Video!
Ótimo.... Muito bom....
1 Brasileiro por aqui! That’s cool
thank you very much. it helped a lot. Can you design a code to move priority countries (taking example from your sheet) at top
You need to have a priority list in the form of an array and then put it into an automatic list as input in a custom sorting (alternatively, get the values in a range as priority list or write them directly as comma delimited). Let's say you want to sort by country size Germany, France, Italy,... would be like this:
Dim PrioList As Variant
PrioList = Array("Germany", "France", "Italy", "Spain", "Poland")
Application.AddCustomList ListArray:=PrioList
Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=Application.CustomListCount + 1
Application.DeleteCustomList Application.CustomListCount
thanks, but showing run time error 1004, all merged cell need to be the same size@@ExcelMacroMania
@@VijaySingh-sm5vo You need to use that code before merging the cells, with the original table, just like in the video, first sort, then merge. Good luck!
thank you i will try @@ExcelMacroMania