How to get multi-row sort/filtering headers in excel
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a spreadsheet which uses 2 rows for header information. Filtering by selecting a column is implicitly assuming only 1 row of header information. Sorting has a header row checkbox but that only toggles treating the first row as a header.
Is there a way to make Excel treat the first two rows as headers?
microsoft-excel microsoft-office
add a comment |
I have a spreadsheet which uses 2 rows for header information. Filtering by selecting a column is implicitly assuming only 1 row of header information. Sorting has a header row checkbox but that only toggles treating the first row as a header.
Is there a way to make Excel treat the first two rows as headers?
microsoft-excel microsoft-office
add a comment |
I have a spreadsheet which uses 2 rows for header information. Filtering by selecting a column is implicitly assuming only 1 row of header information. Sorting has a header row checkbox but that only toggles treating the first row as a header.
Is there a way to make Excel treat the first two rows as headers?
microsoft-excel microsoft-office
I have a spreadsheet which uses 2 rows for header information. Filtering by selecting a column is implicitly assuming only 1 row of header information. Sorting has a header row checkbox but that only toggles treating the first row as a header.
Is there a way to make Excel treat the first two rows as headers?
microsoft-excel microsoft-office
microsoft-excel microsoft-office
edited Nov 29 '17 at 23:14
Shawn
130213
130213
asked Oct 29 '09 at 20:50
Dan NeelyDan Neely
2,11921943
2,11921943
add a comment |
add a comment |
13 Answers
13
active
oldest
votes
No. Omit the first row from your range when you auto filter. This way the auto filter buttons appear only on your bottom header row and the data gets filtered. I expect that right now your second header row is getting pulled into your 'data'.
You can't select a single cell and have excel figure this out. You have to select the range of cells you want excel to include.
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
add a comment |
An easy way to accomplish the sort function using multiple header rows is to insert a blank row just above the row you want to sort by (ideally, it is bottom-most in your header. If not, make it so.). Then click on the 'row' number highlighting the empty row. Right click that row and select "Hide'. The new, empty row will vanish leaving your header the way you wanted it to look and Excel will interpret your category row as the header.
add a comment |
If you select an entire row (by selecting the row number to the left of the row) and then enable your filter (Data > Filter) then it will give you filters for everything below the selected row and ignore everything above it.
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
add a comment |
To filter a list with 2 header rows, where the second row contains the column headings, here is what I did.
- Cut the first row
- Turn filtering off
- Turn filtering on again so that the second row is filtered. This tells Excel which is the row with the column headings.
- Paste the first row back in again above the row with the filters and column headings
- Check to see if the filter now works, with the column headings on the second row.
add a comment |
Okay, the following works in Excel 2010, even after saving the file back as an Excel 2007 and re-opening (so presumably works in Excel 2007 as well...)
Assuming a 3 row header. Set the spreadsheet filter range to Start at cell $A$4 and ensure that it covers the full extent of data you want to sort. SAVE THE FILE.
Henceforth, any sort will treat rows 1 to 3 as headers and therefore sort from row 4 onwards only. - UNLESS you change or cancel the filter range....
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
add a comment |
I know that I'm on SuperUser and not on StackOverflow, but the solution to this problem can be found in using VBA code on Excel 2016.
I have similar (more complex) problem.
I want to add some filters on explicit columns but not on row 1 only on row 2 as you can see in following screen's capture.
I have tried using Excel GUI but this seems impossible, so I have written following code:
'********************************************************
'* SetFilter()
'********************************************************
'* PUBLIC method to call to define CUSTOM AutoFilter
'* on complex header.
'********************************************************
Sub SetFilter()
'Compute last row number
Dim nLast As Long
nLast = Range("A" & Rows.Count).End(xlUp).Row
'Lock screen update
Application.ScreenUpdating = False
'Unmerge merged cells to allow adding filter
Range("A1:A2").MergeCells = False
Range("B1:B2").MergeCells = False
Range("C1:C2").MergeCells = False
Range("D1:D2").MergeCells = False
Range("E1:E2").MergeCells = False
Range("F1:F2").MergeCells = False
'Add filter on row 2 and not 1
Range("A2:Z" & nLast).Select
Selection.AutoFilter
'Remove (or Hide) filter combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("G"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("H"), VisibleDropDown:=False
'Merge unmerged cells to restore previous state
Range("A1:A2").MergeCells = True
Range("B1:B2").MergeCells = True
Range("C1:C2").MergeCells = True
Range("D1:D2").MergeCells = True
Range("E1:E2").MergeCells = True
Range("F1:F2").MergeCells = True
'Unlock screen update
Application.ScreenUpdating = True
End Sub
'********************************************************
'* GetColumnIndex()
'********************************************************
'* return column's index from column letters
'********************************************************
Function GetColumnIndex(sColLetter As String) As Integer
Dim n As Integer: n = 0
Dim iMax As Integer: iMax = Len(sColLetter)
Dim i As Integer
Dim sChar As String
Dim c As Integer
For i = 1 To iMax
sChar = Mid(sColLetter, i, 1)
c = 1 + Asc(sChar) - Asc("A")
n = n * 26 + c
Next
If n = 1 Then
n = 1
End If
GetColumnIndex = n
End Function
The logic of this code is
A. Unmerge vertically merged header cells to allow adding filter on row
2
Range("A1:A2").MergeCells = False
Cells A1 and A2 are unmerged.
B. Add AutoFilter on all cells of row 2
Range("A2:Z" & nLast).AutoFilter
AutoFilter is generated for cells in all rows except row 1.
C. Remove or hide FILTER Combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
DropBox of Column "C" is hidden.
D. Merge unmerged cells to restore original state
Range("A1:A2").MergeCells = True
Cells A1 and A2 are merged again.
add a comment |
Excel 2007 can smartly detect if you have multi-row headers. I made a simple experiment just now before writing this.
Before making your first sort, position the cursor right below the header. That's it! Sorting is fine, filtering is fine. Excel ignored the 1st row of my headers. It just processes the 2nd row as the real header.
3
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
add a comment |
Highlight the cells that need to be sorted (all except the headers) and then select filter.
add a comment |
I am using Excel 2010. To retain the heading rows (e.g. the first 4 rows), highlight row 5 and then turn on the filters. Rows 1 - 4 are excluded from the filter.
add a comment |
I had the same issue, so everyone's contribution led me to the way the works for me (so far).
ADD a blank row below your Multi-row(s) Header (if your header is 5 rows of info and/or odd cell sizes, then your NEW blank row will be Row6).
Click on Row6 (to the far left/ actually click the "6" (Excel Row #) to select the entire row / to infinity). BE sure NOT to click any other CELL, until you have completed #3 and #4 below, or you will 'Deselect' the row. You want to keep it 'Selected'.
Go to the VIEW tab> Freeze Panes >Unfreeze (do this first to clear it) >Freeze. This will freeze your 5 row header & also the blank row (row6).
Hold Down "ALT", then press the following keys: D, F, F (this is the shortcut to turnON & turnOff/clear all filters on the sheet.
From this point forward, whenever you return to use this sheet & you need those Filters on (if you previously turned them off for any reason), then >Select your Blank Row (as explained in #2); >TurnON all your filters (as explained in #4).
Sorry to be so wordy, but after you do it a few times, will likely love it (if you use Filters a lot).
add a comment |
Step 1
Highlight the bottom header row. and then You can select just the cells in a row, or select the entire row.
Step 2
next click on "Sort & Filter" on the Home tab, then you can select "Filter." Excel adds filter arrows to all the column names.
Step 3
then click an arrow and later select a sorting option to sort the entire table by that column.
Step 4
finally click on "Sort & Filter" and select "Filter" again if you want to get rid of the arrows, but keep the sorting area defined by the filter. now you can sort normally, Excel ignores the extra header rows
add a comment |
Another way to accomplish in some cases is to enter a value in the second column that will cause the filter to include it, then make the text of that cell match the background colour of the cell. Not that pretty since the header (row 1) will not be horizontally centred in the cell but it will work...
add a comment |
I had the same problem and found a solution that works for me.
For every row in the header that you don't want to see, you make te letters white (or the backgroundcolor).
When you sort you don't see all the same headers in the rows. To bad when you want to change something, but in that case you can also make them light grey.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f62758%2fhow-to-get-multi-row-sort-filtering-headers-in-excel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
No. Omit the first row from your range when you auto filter. This way the auto filter buttons appear only on your bottom header row and the data gets filtered. I expect that right now your second header row is getting pulled into your 'data'.
You can't select a single cell and have excel figure this out. You have to select the range of cells you want excel to include.
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
add a comment |
No. Omit the first row from your range when you auto filter. This way the auto filter buttons appear only on your bottom header row and the data gets filtered. I expect that right now your second header row is getting pulled into your 'data'.
You can't select a single cell and have excel figure this out. You have to select the range of cells you want excel to include.
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
add a comment |
No. Omit the first row from your range when you auto filter. This way the auto filter buttons appear only on your bottom header row and the data gets filtered. I expect that right now your second header row is getting pulled into your 'data'.
You can't select a single cell and have excel figure this out. You have to select the range of cells you want excel to include.
No. Omit the first row from your range when you auto filter. This way the auto filter buttons appear only on your bottom header row and the data gets filtered. I expect that right now your second header row is getting pulled into your 'data'.
You can't select a single cell and have excel figure this out. You have to select the range of cells you want excel to include.
answered Oct 29 '09 at 22:12
DaveParilloDaveParillo
13.2k3444
13.2k3444
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
add a comment |
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
It is. I didn't realize I could select a specific cell to start the filtering at, as opposed to doing a column select.
– Dan Neely
Nov 12 '09 at 14:45
add a comment |
An easy way to accomplish the sort function using multiple header rows is to insert a blank row just above the row you want to sort by (ideally, it is bottom-most in your header. If not, make it so.). Then click on the 'row' number highlighting the empty row. Right click that row and select "Hide'. The new, empty row will vanish leaving your header the way you wanted it to look and Excel will interpret your category row as the header.
add a comment |
An easy way to accomplish the sort function using multiple header rows is to insert a blank row just above the row you want to sort by (ideally, it is bottom-most in your header. If not, make it so.). Then click on the 'row' number highlighting the empty row. Right click that row and select "Hide'. The new, empty row will vanish leaving your header the way you wanted it to look and Excel will interpret your category row as the header.
add a comment |
An easy way to accomplish the sort function using multiple header rows is to insert a blank row just above the row you want to sort by (ideally, it is bottom-most in your header. If not, make it so.). Then click on the 'row' number highlighting the empty row. Right click that row and select "Hide'. The new, empty row will vanish leaving your header the way you wanted it to look and Excel will interpret your category row as the header.
An easy way to accomplish the sort function using multiple header rows is to insert a blank row just above the row you want to sort by (ideally, it is bottom-most in your header. If not, make it so.). Then click on the 'row' number highlighting the empty row. Right click that row and select "Hide'. The new, empty row will vanish leaving your header the way you wanted it to look and Excel will interpret your category row as the header.
answered Jul 7 '12 at 17:23
George CahillGeorge Cahill
7111
7111
add a comment |
add a comment |
If you select an entire row (by selecting the row number to the left of the row) and then enable your filter (Data > Filter) then it will give you filters for everything below the selected row and ignore everything above it.
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
add a comment |
If you select an entire row (by selecting the row number to the left of the row) and then enable your filter (Data > Filter) then it will give you filters for everything below the selected row and ignore everything above it.
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
add a comment |
If you select an entire row (by selecting the row number to the left of the row) and then enable your filter (Data > Filter) then it will give you filters for everything below the selected row and ignore everything above it.
If you select an entire row (by selecting the row number to the left of the row) and then enable your filter (Data > Filter) then it will give you filters for everything below the selected row and ignore everything above it.
answered Jan 20 '14 at 17:20
user291695user291695
211
211
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
add a comment |
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
This is the correct answer and the easiest. This works in excel 2016 since this is a much older question.
– Shawn
Nov 29 '17 at 21:41
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
Thank you! Why is everyone else on here doing it so complicated?
– user291695
Dec 1 '17 at 4:20
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
@user291695: I'm guessing from the date on OP that that's how it was probably done for an older version of MS Office as in older answers and the newer answers just don't make sense. Don't know for sure though.
– Fr0zenFyr
Feb 9 '18 at 9:02
add a comment |
To filter a list with 2 header rows, where the second row contains the column headings, here is what I did.
- Cut the first row
- Turn filtering off
- Turn filtering on again so that the second row is filtered. This tells Excel which is the row with the column headings.
- Paste the first row back in again above the row with the filters and column headings
- Check to see if the filter now works, with the column headings on the second row.
add a comment |
To filter a list with 2 header rows, where the second row contains the column headings, here is what I did.
- Cut the first row
- Turn filtering off
- Turn filtering on again so that the second row is filtered. This tells Excel which is the row with the column headings.
- Paste the first row back in again above the row with the filters and column headings
- Check to see if the filter now works, with the column headings on the second row.
add a comment |
To filter a list with 2 header rows, where the second row contains the column headings, here is what I did.
- Cut the first row
- Turn filtering off
- Turn filtering on again so that the second row is filtered. This tells Excel which is the row with the column headings.
- Paste the first row back in again above the row with the filters and column headings
- Check to see if the filter now works, with the column headings on the second row.
To filter a list with 2 header rows, where the second row contains the column headings, here is what I did.
- Cut the first row
- Turn filtering off
- Turn filtering on again so that the second row is filtered. This tells Excel which is the row with the column headings.
- Paste the first row back in again above the row with the filters and column headings
- Check to see if the filter now works, with the column headings on the second row.
edited Mar 3 '13 at 1:57
answered Mar 1 '13 at 15:40
PeterJHillPeterJHill
112
112
add a comment |
add a comment |
Okay, the following works in Excel 2010, even after saving the file back as an Excel 2007 and re-opening (so presumably works in Excel 2007 as well...)
Assuming a 3 row header. Set the spreadsheet filter range to Start at cell $A$4 and ensure that it covers the full extent of data you want to sort. SAVE THE FILE.
Henceforth, any sort will treat rows 1 to 3 as headers and therefore sort from row 4 onwards only. - UNLESS you change or cancel the filter range....
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
add a comment |
Okay, the following works in Excel 2010, even after saving the file back as an Excel 2007 and re-opening (so presumably works in Excel 2007 as well...)
Assuming a 3 row header. Set the spreadsheet filter range to Start at cell $A$4 and ensure that it covers the full extent of data you want to sort. SAVE THE FILE.
Henceforth, any sort will treat rows 1 to 3 as headers and therefore sort from row 4 onwards only. - UNLESS you change or cancel the filter range....
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
add a comment |
Okay, the following works in Excel 2010, even after saving the file back as an Excel 2007 and re-opening (so presumably works in Excel 2007 as well...)
Assuming a 3 row header. Set the spreadsheet filter range to Start at cell $A$4 and ensure that it covers the full extent of data you want to sort. SAVE THE FILE.
Henceforth, any sort will treat rows 1 to 3 as headers and therefore sort from row 4 onwards only. - UNLESS you change or cancel the filter range....
Okay, the following works in Excel 2010, even after saving the file back as an Excel 2007 and re-opening (so presumably works in Excel 2007 as well...)
Assuming a 3 row header. Set the spreadsheet filter range to Start at cell $A$4 and ensure that it covers the full extent of data you want to sort. SAVE THE FILE.
Henceforth, any sort will treat rows 1 to 3 as headers and therefore sort from row 4 onwards only. - UNLESS you change or cancel the filter range....
answered Jul 23 '13 at 6:39
deedgessdeedgess
111
111
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
add a comment |
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
The response from deedgess worked for me. When you add a filter, excel assumes every row above it is a header. In my case, I have a 2 row header. I selected row 2 and turned on the filter. Then I selected custom sort and checked the box for header. When the sort happened, both row 1 and row 2 remained as header.
– user254440
Sep 15 '13 at 17:11
add a comment |
I know that I'm on SuperUser and not on StackOverflow, but the solution to this problem can be found in using VBA code on Excel 2016.
I have similar (more complex) problem.
I want to add some filters on explicit columns but not on row 1 only on row 2 as you can see in following screen's capture.
I have tried using Excel GUI but this seems impossible, so I have written following code:
'********************************************************
'* SetFilter()
'********************************************************
'* PUBLIC method to call to define CUSTOM AutoFilter
'* on complex header.
'********************************************************
Sub SetFilter()
'Compute last row number
Dim nLast As Long
nLast = Range("A" & Rows.Count).End(xlUp).Row
'Lock screen update
Application.ScreenUpdating = False
'Unmerge merged cells to allow adding filter
Range("A1:A2").MergeCells = False
Range("B1:B2").MergeCells = False
Range("C1:C2").MergeCells = False
Range("D1:D2").MergeCells = False
Range("E1:E2").MergeCells = False
Range("F1:F2").MergeCells = False
'Add filter on row 2 and not 1
Range("A2:Z" & nLast).Select
Selection.AutoFilter
'Remove (or Hide) filter combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("G"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("H"), VisibleDropDown:=False
'Merge unmerged cells to restore previous state
Range("A1:A2").MergeCells = True
Range("B1:B2").MergeCells = True
Range("C1:C2").MergeCells = True
Range("D1:D2").MergeCells = True
Range("E1:E2").MergeCells = True
Range("F1:F2").MergeCells = True
'Unlock screen update
Application.ScreenUpdating = True
End Sub
'********************************************************
'* GetColumnIndex()
'********************************************************
'* return column's index from column letters
'********************************************************
Function GetColumnIndex(sColLetter As String) As Integer
Dim n As Integer: n = 0
Dim iMax As Integer: iMax = Len(sColLetter)
Dim i As Integer
Dim sChar As String
Dim c As Integer
For i = 1 To iMax
sChar = Mid(sColLetter, i, 1)
c = 1 + Asc(sChar) - Asc("A")
n = n * 26 + c
Next
If n = 1 Then
n = 1
End If
GetColumnIndex = n
End Function
The logic of this code is
A. Unmerge vertically merged header cells to allow adding filter on row
2
Range("A1:A2").MergeCells = False
Cells A1 and A2 are unmerged.
B. Add AutoFilter on all cells of row 2
Range("A2:Z" & nLast).AutoFilter
AutoFilter is generated for cells in all rows except row 1.
C. Remove or hide FILTER Combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
DropBox of Column "C" is hidden.
D. Merge unmerged cells to restore original state
Range("A1:A2").MergeCells = True
Cells A1 and A2 are merged again.
add a comment |
I know that I'm on SuperUser and not on StackOverflow, but the solution to this problem can be found in using VBA code on Excel 2016.
I have similar (more complex) problem.
I want to add some filters on explicit columns but not on row 1 only on row 2 as you can see in following screen's capture.
I have tried using Excel GUI but this seems impossible, so I have written following code:
'********************************************************
'* SetFilter()
'********************************************************
'* PUBLIC method to call to define CUSTOM AutoFilter
'* on complex header.
'********************************************************
Sub SetFilter()
'Compute last row number
Dim nLast As Long
nLast = Range("A" & Rows.Count).End(xlUp).Row
'Lock screen update
Application.ScreenUpdating = False
'Unmerge merged cells to allow adding filter
Range("A1:A2").MergeCells = False
Range("B1:B2").MergeCells = False
Range("C1:C2").MergeCells = False
Range("D1:D2").MergeCells = False
Range("E1:E2").MergeCells = False
Range("F1:F2").MergeCells = False
'Add filter on row 2 and not 1
Range("A2:Z" & nLast).Select
Selection.AutoFilter
'Remove (or Hide) filter combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("G"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("H"), VisibleDropDown:=False
'Merge unmerged cells to restore previous state
Range("A1:A2").MergeCells = True
Range("B1:B2").MergeCells = True
Range("C1:C2").MergeCells = True
Range("D1:D2").MergeCells = True
Range("E1:E2").MergeCells = True
Range("F1:F2").MergeCells = True
'Unlock screen update
Application.ScreenUpdating = True
End Sub
'********************************************************
'* GetColumnIndex()
'********************************************************
'* return column's index from column letters
'********************************************************
Function GetColumnIndex(sColLetter As String) As Integer
Dim n As Integer: n = 0
Dim iMax As Integer: iMax = Len(sColLetter)
Dim i As Integer
Dim sChar As String
Dim c As Integer
For i = 1 To iMax
sChar = Mid(sColLetter, i, 1)
c = 1 + Asc(sChar) - Asc("A")
n = n * 26 + c
Next
If n = 1 Then
n = 1
End If
GetColumnIndex = n
End Function
The logic of this code is
A. Unmerge vertically merged header cells to allow adding filter on row
2
Range("A1:A2").MergeCells = False
Cells A1 and A2 are unmerged.
B. Add AutoFilter on all cells of row 2
Range("A2:Z" & nLast).AutoFilter
AutoFilter is generated for cells in all rows except row 1.
C. Remove or hide FILTER Combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
DropBox of Column "C" is hidden.
D. Merge unmerged cells to restore original state
Range("A1:A2").MergeCells = True
Cells A1 and A2 are merged again.
add a comment |
I know that I'm on SuperUser and not on StackOverflow, but the solution to this problem can be found in using VBA code on Excel 2016.
I have similar (more complex) problem.
I want to add some filters on explicit columns but not on row 1 only on row 2 as you can see in following screen's capture.
I have tried using Excel GUI but this seems impossible, so I have written following code:
'********************************************************
'* SetFilter()
'********************************************************
'* PUBLIC method to call to define CUSTOM AutoFilter
'* on complex header.
'********************************************************
Sub SetFilter()
'Compute last row number
Dim nLast As Long
nLast = Range("A" & Rows.Count).End(xlUp).Row
'Lock screen update
Application.ScreenUpdating = False
'Unmerge merged cells to allow adding filter
Range("A1:A2").MergeCells = False
Range("B1:B2").MergeCells = False
Range("C1:C2").MergeCells = False
Range("D1:D2").MergeCells = False
Range("E1:E2").MergeCells = False
Range("F1:F2").MergeCells = False
'Add filter on row 2 and not 1
Range("A2:Z" & nLast).Select
Selection.AutoFilter
'Remove (or Hide) filter combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("G"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("H"), VisibleDropDown:=False
'Merge unmerged cells to restore previous state
Range("A1:A2").MergeCells = True
Range("B1:B2").MergeCells = True
Range("C1:C2").MergeCells = True
Range("D1:D2").MergeCells = True
Range("E1:E2").MergeCells = True
Range("F1:F2").MergeCells = True
'Unlock screen update
Application.ScreenUpdating = True
End Sub
'********************************************************
'* GetColumnIndex()
'********************************************************
'* return column's index from column letters
'********************************************************
Function GetColumnIndex(sColLetter As String) As Integer
Dim n As Integer: n = 0
Dim iMax As Integer: iMax = Len(sColLetter)
Dim i As Integer
Dim sChar As String
Dim c As Integer
For i = 1 To iMax
sChar = Mid(sColLetter, i, 1)
c = 1 + Asc(sChar) - Asc("A")
n = n * 26 + c
Next
If n = 1 Then
n = 1
End If
GetColumnIndex = n
End Function
The logic of this code is
A. Unmerge vertically merged header cells to allow adding filter on row
2
Range("A1:A2").MergeCells = False
Cells A1 and A2 are unmerged.
B. Add AutoFilter on all cells of row 2
Range("A2:Z" & nLast).AutoFilter
AutoFilter is generated for cells in all rows except row 1.
C. Remove or hide FILTER Combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
DropBox of Column "C" is hidden.
D. Merge unmerged cells to restore original state
Range("A1:A2").MergeCells = True
Cells A1 and A2 are merged again.
I know that I'm on SuperUser and not on StackOverflow, but the solution to this problem can be found in using VBA code on Excel 2016.
I have similar (more complex) problem.
I want to add some filters on explicit columns but not on row 1 only on row 2 as you can see in following screen's capture.
I have tried using Excel GUI but this seems impossible, so I have written following code:
'********************************************************
'* SetFilter()
'********************************************************
'* PUBLIC method to call to define CUSTOM AutoFilter
'* on complex header.
'********************************************************
Sub SetFilter()
'Compute last row number
Dim nLast As Long
nLast = Range("A" & Rows.Count).End(xlUp).Row
'Lock screen update
Application.ScreenUpdating = False
'Unmerge merged cells to allow adding filter
Range("A1:A2").MergeCells = False
Range("B1:B2").MergeCells = False
Range("C1:C2").MergeCells = False
Range("D1:D2").MergeCells = False
Range("E1:E2").MergeCells = False
Range("F1:F2").MergeCells = False
'Add filter on row 2 and not 1
Range("A2:Z" & nLast).Select
Selection.AutoFilter
'Remove (or Hide) filter combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("G"), VisibleDropDown:=False
Selection.AutoFilter Field:=GetColumnIndex("H"), VisibleDropDown:=False
'Merge unmerged cells to restore previous state
Range("A1:A2").MergeCells = True
Range("B1:B2").MergeCells = True
Range("C1:C2").MergeCells = True
Range("D1:D2").MergeCells = True
Range("E1:E2").MergeCells = True
Range("F1:F2").MergeCells = True
'Unlock screen update
Application.ScreenUpdating = True
End Sub
'********************************************************
'* GetColumnIndex()
'********************************************************
'* return column's index from column letters
'********************************************************
Function GetColumnIndex(sColLetter As String) As Integer
Dim n As Integer: n = 0
Dim iMax As Integer: iMax = Len(sColLetter)
Dim i As Integer
Dim sChar As String
Dim c As Integer
For i = 1 To iMax
sChar = Mid(sColLetter, i, 1)
c = 1 + Asc(sChar) - Asc("A")
n = n * 26 + c
Next
If n = 1 Then
n = 1
End If
GetColumnIndex = n
End Function
The logic of this code is
A. Unmerge vertically merged header cells to allow adding filter on row
2
Range("A1:A2").MergeCells = False
Cells A1 and A2 are unmerged.
B. Add AutoFilter on all cells of row 2
Range("A2:Z" & nLast).AutoFilter
AutoFilter is generated for cells in all rows except row 1.
C. Remove or hide FILTER Combobox for some columns
Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=False
DropBox of Column "C" is hidden.
D. Merge unmerged cells to restore original state
Range("A1:A2").MergeCells = True
Cells A1 and A2 are merged again.
edited Feb 7 at 12:05
answered Feb 7 at 11:08
schlebeschlebe
13310
13310
add a comment |
add a comment |
Excel 2007 can smartly detect if you have multi-row headers. I made a simple experiment just now before writing this.
Before making your first sort, position the cursor right below the header. That's it! Sorting is fine, filtering is fine. Excel ignored the 1st row of my headers. It just processes the 2nd row as the real header.
3
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
add a comment |
Excel 2007 can smartly detect if you have multi-row headers. I made a simple experiment just now before writing this.
Before making your first sort, position the cursor right below the header. That's it! Sorting is fine, filtering is fine. Excel ignored the 1st row of my headers. It just processes the 2nd row as the real header.
3
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
add a comment |
Excel 2007 can smartly detect if you have multi-row headers. I made a simple experiment just now before writing this.
Before making your first sort, position the cursor right below the header. That's it! Sorting is fine, filtering is fine. Excel ignored the 1st row of my headers. It just processes the 2nd row as the real header.
Excel 2007 can smartly detect if you have multi-row headers. I made a simple experiment just now before writing this.
Before making your first sort, position the cursor right below the header. That's it! Sorting is fine, filtering is fine. Excel ignored the 1st row of my headers. It just processes the 2nd row as the real header.
answered Oct 29 '09 at 22:12
thenonhackerthenonhacker
323216
323216
3
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
add a comment |
3
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
3
3
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
Nope, this doesn't work. It's true that Excel 07 can autodetect multi-row headers in some cases, but it's based on cell contents, not on which cell you click. For example, if the first two rows are text and everything below is numeric, then Excel will assume the first 2 rows are both headers.
– Josh
Mar 23 '10 at 16:30
add a comment |
Highlight the cells that need to be sorted (all except the headers) and then select filter.
add a comment |
Highlight the cells that need to be sorted (all except the headers) and then select filter.
add a comment |
Highlight the cells that need to be sorted (all except the headers) and then select filter.
Highlight the cells that need to be sorted (all except the headers) and then select filter.
edited Nov 3 '12 at 3:18
Isaac Rabinovitch
2,6011828
2,6011828
answered Mar 28 '12 at 5:47
LaurahLaurah
1
1
add a comment |
add a comment |
I am using Excel 2010. To retain the heading rows (e.g. the first 4 rows), highlight row 5 and then turn on the filters. Rows 1 - 4 are excluded from the filter.
add a comment |
I am using Excel 2010. To retain the heading rows (e.g. the first 4 rows), highlight row 5 and then turn on the filters. Rows 1 - 4 are excluded from the filter.
add a comment |
I am using Excel 2010. To retain the heading rows (e.g. the first 4 rows), highlight row 5 and then turn on the filters. Rows 1 - 4 are excluded from the filter.
I am using Excel 2010. To retain the heading rows (e.g. the first 4 rows), highlight row 5 and then turn on the filters. Rows 1 - 4 are excluded from the filter.
edited Sep 16 '13 at 23:59
nc4pk
7,292115268
7,292115268
answered Sep 16 '13 at 23:32
Tony BrayTony Bray
1
1
add a comment |
add a comment |
I had the same issue, so everyone's contribution led me to the way the works for me (so far).
ADD a blank row below your Multi-row(s) Header (if your header is 5 rows of info and/or odd cell sizes, then your NEW blank row will be Row6).
Click on Row6 (to the far left/ actually click the "6" (Excel Row #) to select the entire row / to infinity). BE sure NOT to click any other CELL, until you have completed #3 and #4 below, or you will 'Deselect' the row. You want to keep it 'Selected'.
Go to the VIEW tab> Freeze Panes >Unfreeze (do this first to clear it) >Freeze. This will freeze your 5 row header & also the blank row (row6).
Hold Down "ALT", then press the following keys: D, F, F (this is the shortcut to turnON & turnOff/clear all filters on the sheet.
From this point forward, whenever you return to use this sheet & you need those Filters on (if you previously turned them off for any reason), then >Select your Blank Row (as explained in #2); >TurnON all your filters (as explained in #4).
Sorry to be so wordy, but after you do it a few times, will likely love it (if you use Filters a lot).
add a comment |
I had the same issue, so everyone's contribution led me to the way the works for me (so far).
ADD a blank row below your Multi-row(s) Header (if your header is 5 rows of info and/or odd cell sizes, then your NEW blank row will be Row6).
Click on Row6 (to the far left/ actually click the "6" (Excel Row #) to select the entire row / to infinity). BE sure NOT to click any other CELL, until you have completed #3 and #4 below, or you will 'Deselect' the row. You want to keep it 'Selected'.
Go to the VIEW tab> Freeze Panes >Unfreeze (do this first to clear it) >Freeze. This will freeze your 5 row header & also the blank row (row6).
Hold Down "ALT", then press the following keys: D, F, F (this is the shortcut to turnON & turnOff/clear all filters on the sheet.
From this point forward, whenever you return to use this sheet & you need those Filters on (if you previously turned them off for any reason), then >Select your Blank Row (as explained in #2); >TurnON all your filters (as explained in #4).
Sorry to be so wordy, but after you do it a few times, will likely love it (if you use Filters a lot).
add a comment |
I had the same issue, so everyone's contribution led me to the way the works for me (so far).
ADD a blank row below your Multi-row(s) Header (if your header is 5 rows of info and/or odd cell sizes, then your NEW blank row will be Row6).
Click on Row6 (to the far left/ actually click the "6" (Excel Row #) to select the entire row / to infinity). BE sure NOT to click any other CELL, until you have completed #3 and #4 below, or you will 'Deselect' the row. You want to keep it 'Selected'.
Go to the VIEW tab> Freeze Panes >Unfreeze (do this first to clear it) >Freeze. This will freeze your 5 row header & also the blank row (row6).
Hold Down "ALT", then press the following keys: D, F, F (this is the shortcut to turnON & turnOff/clear all filters on the sheet.
From this point forward, whenever you return to use this sheet & you need those Filters on (if you previously turned them off for any reason), then >Select your Blank Row (as explained in #2); >TurnON all your filters (as explained in #4).
Sorry to be so wordy, but after you do it a few times, will likely love it (if you use Filters a lot).
I had the same issue, so everyone's contribution led me to the way the works for me (so far).
ADD a blank row below your Multi-row(s) Header (if your header is 5 rows of info and/or odd cell sizes, then your NEW blank row will be Row6).
Click on Row6 (to the far left/ actually click the "6" (Excel Row #) to select the entire row / to infinity). BE sure NOT to click any other CELL, until you have completed #3 and #4 below, or you will 'Deselect' the row. You want to keep it 'Selected'.
Go to the VIEW tab> Freeze Panes >Unfreeze (do this first to clear it) >Freeze. This will freeze your 5 row header & also the blank row (row6).
Hold Down "ALT", then press the following keys: D, F, F (this is the shortcut to turnON & turnOff/clear all filters on the sheet.
From this point forward, whenever you return to use this sheet & you need those Filters on (if you previously turned them off for any reason), then >Select your Blank Row (as explained in #2); >TurnON all your filters (as explained in #4).
Sorry to be so wordy, but after you do it a few times, will likely love it (if you use Filters a lot).
edited Jan 30 '15 at 19:46
Ƭᴇcʜιᴇ007
100k14158221
100k14158221
answered Jan 30 '15 at 19:20
JohnBJohnB
1
1
add a comment |
add a comment |
Step 1
Highlight the bottom header row. and then You can select just the cells in a row, or select the entire row.
Step 2
next click on "Sort & Filter" on the Home tab, then you can select "Filter." Excel adds filter arrows to all the column names.
Step 3
then click an arrow and later select a sorting option to sort the entire table by that column.
Step 4
finally click on "Sort & Filter" and select "Filter" again if you want to get rid of the arrows, but keep the sorting area defined by the filter. now you can sort normally, Excel ignores the extra header rows
add a comment |
Step 1
Highlight the bottom header row. and then You can select just the cells in a row, or select the entire row.
Step 2
next click on "Sort & Filter" on the Home tab, then you can select "Filter." Excel adds filter arrows to all the column names.
Step 3
then click an arrow and later select a sorting option to sort the entire table by that column.
Step 4
finally click on "Sort & Filter" and select "Filter" again if you want to get rid of the arrows, but keep the sorting area defined by the filter. now you can sort normally, Excel ignores the extra header rows
add a comment |
Step 1
Highlight the bottom header row. and then You can select just the cells in a row, or select the entire row.
Step 2
next click on "Sort & Filter" on the Home tab, then you can select "Filter." Excel adds filter arrows to all the column names.
Step 3
then click an arrow and later select a sorting option to sort the entire table by that column.
Step 4
finally click on "Sort & Filter" and select "Filter" again if you want to get rid of the arrows, but keep the sorting area defined by the filter. now you can sort normally, Excel ignores the extra header rows
Step 1
Highlight the bottom header row. and then You can select just the cells in a row, or select the entire row.
Step 2
next click on "Sort & Filter" on the Home tab, then you can select "Filter." Excel adds filter arrows to all the column names.
Step 3
then click an arrow and later select a sorting option to sort the entire table by that column.
Step 4
finally click on "Sort & Filter" and select "Filter" again if you want to get rid of the arrows, but keep the sorting area defined by the filter. now you can sort normally, Excel ignores the extra header rows
answered Feb 7 at 12:46
pte coachingpte coaching
1
1
add a comment |
add a comment |
Another way to accomplish in some cases is to enter a value in the second column that will cause the filter to include it, then make the text of that cell match the background colour of the cell. Not that pretty since the header (row 1) will not be horizontally centred in the cell but it will work...
add a comment |
Another way to accomplish in some cases is to enter a value in the second column that will cause the filter to include it, then make the text of that cell match the background colour of the cell. Not that pretty since the header (row 1) will not be horizontally centred in the cell but it will work...
add a comment |
Another way to accomplish in some cases is to enter a value in the second column that will cause the filter to include it, then make the text of that cell match the background colour of the cell. Not that pretty since the header (row 1) will not be horizontally centred in the cell but it will work...
Another way to accomplish in some cases is to enter a value in the second column that will cause the filter to include it, then make the text of that cell match the background colour of the cell. Not that pretty since the header (row 1) will not be horizontally centred in the cell but it will work...
answered May 2 '12 at 18:00
TonyTony
1
1
add a comment |
add a comment |
I had the same problem and found a solution that works for me.
For every row in the header that you don't want to see, you make te letters white (or the backgroundcolor).
When you sort you don't see all the same headers in the rows. To bad when you want to change something, but in that case you can also make them light grey.
add a comment |
I had the same problem and found a solution that works for me.
For every row in the header that you don't want to see, you make te letters white (or the backgroundcolor).
When you sort you don't see all the same headers in the rows. To bad when you want to change something, but in that case you can also make them light grey.
add a comment |
I had the same problem and found a solution that works for me.
For every row in the header that you don't want to see, you make te letters white (or the backgroundcolor).
When you sort you don't see all the same headers in the rows. To bad when you want to change something, but in that case you can also make them light grey.
I had the same problem and found a solution that works for me.
For every row in the header that you don't want to see, you make te letters white (or the backgroundcolor).
When you sort you don't see all the same headers in the rows. To bad when you want to change something, but in that case you can also make them light grey.
answered Sep 10 '13 at 17:00
Job OosterhuisJob Oosterhuis
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f62758%2fhow-to-get-multi-row-sort-filtering-headers-in-excel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown