You are here:

Excel/macro for sorting sheet without sorting frozen rows


I am referring to this question that was asked of you:

Excel/Sorting Macro for Excel sheet with frozen cells
Expert: Aidan Heritage - 11/5/2007

This question is exactly what I'm trying to do, but i do not speak in macro's- my excel level is very low. i recently took a macro class that involved editing the macro's; which is what i think you're referring to.

I am trying to put buttons on a spreadsheet for co-workers with way less excel skills than me to sort by certain criteria.
But, I want the first 4 rows to be omitted from the sort because it is the heading and categories and macro buttons. So i want everything on the sheet to sort starting on row 5. this is also a sheet that rows are being added to, so i want to make sure that future additions will be sorted as well.

Can you help me with this?
thank you!

that answer looks valid for you as well -

Range("A5:H" & WorksheetFunction.CountA(Range("A:A"))).Select

was a selection of cells from a5 to H whatever - I'd PROBABLY now suggest

Range("A5:H" & ActiveSheet.UsedRange.Rows.Count).select

As the sorting part can take the range something like

With ActiveWorkbook.Worksheets("Sheet1").Sort
       .SetRange Range("A5:H" & ActiveSheet.UsedRange.Rows.Count)
       .Header = xlNo
       .MatchCase = False
       .Orientation = xlTopToBottom
       .SortMethod = xlPinYin
   End With

would do it  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Aidan Heritage


I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world!


My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!

©2016 All rights reserved.