Sort an area but in the order of a named range of range?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,197
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I want to select a cell, then run a macro and I need the macro that when runs to sort my data on this basis
Selected cell is first header,
Sort range is from selected cell resize .Resize(500, 6) top row is headers,
then sort the first column but instead of asending or descending sort in the order of named range "Category"
or if easier sheet"Control" Range("G4:G9")

any idease how i can do this?

thanks

Tony
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
How about
VBA Code:
Sub tonywatson()
With ActiveSheet.Sort
   .SortFields.Clear
   .SortFields.Add Selection, , , Join(Application.Transpose(Range("Category")), ",")
   .SetRange Selection.Resize(500, 6)
   .Header = xlYes
   .Apply
End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,616
Messages
6,125,860
Members
449,266
Latest member
davinroach

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top