![]() '* return column's index from column lettersįunction GetColumnIndex(sColLetter As String) As Integerĭim iMax As Integer: iMax = Len(sColLetter)Ī. Unmerge vertically merged header cells to allow adding filter on rowī. Add AutoFilter on all cells of row 2 Range("A2:Z" & nLast).AutoFilterĪutoFilter is generated for cells in all rows except row 1.Ĭ. Is there a way to make Excel treat the first two rows as headers? Merge unmerged cells to restore original state Range("A1:A2").MergeCells = True Remove or hide FILTER Combobox for some columns Selection.AutoFilter Field:=GetColumnIndex("C"), VisibleDropDown:=Falseĭ. Yes there is, if you can make one small change to the first header column. and Excel will now properly ignore both header rows when auto-selecting the sort area: If you are able to merge cells A1 and A2 using "Merge & Center", then Excel will properly identify both rows as header rows.ĭoing an auto-sort on this will automatically (and improperly) select the second row: This obviously won't work if your first column requires both lines for headers, unless you're willing to live with one merged cell with two separate lines of text. While this will look fine, it's isn't semantically correct and could lead to problems in extreme edge cases if one assumes they are separate lines. ![]() This also won't work if A1 is merged horizontally with B1, etc. There is no way around this problem unless you add a dummy column as the first column. If you can't do that, you will have to manually select all the data prior to sorting. Note: all phone numbers were randomly generated with the formula below. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |