Sorting a Selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use a particular spreadsheet everyday, and sort the data in three columns
of the worksheet many times (there is also other data that I do not sort). I
don't have a header row. Until recently, the spreadsheet seemed to know how
I wanted to sort, and the 'sort by' box always appeared with the sort by
defaulting to my previous criteria, seemingly remembering how I had sorted it
last time.

Recently something has happened, and every time I go to sort, first the
dialogue box comes up showing a header row, and when I change it to show no
header row, EACH time it defaults to "sort by column A", even though I always
sort this worksheet by columns B, C, and D. So now I have extra steps to
direct the sheet to sort by B-C-D everytime I want to sort.

Is there a setting somewhere, or was I just lucky before?
 
If you select your range and call this routine, the sort dialog box will
appear with your prefered settings as the default. You can change the
settings before you choose to sort.

Code:
--------------------
Sub SortWithDefaults()
Dim xval As Variant
xval = Application.Dialogs(xlDialogSort).Show(xlTopToBottom, _
Range("b1"), xlAscending, _
Range("c1"), xlAscending, _
Range("d1"), xlAscending, xlYes, 1, False)

End Sub
 
Thanks - now I'm really going to show my ignorance. What do I do with the
code you provided? Is it a macro?

The problem self corrected briefly when I changed the first item in row A to
something else (it had been in the A1 position for a long time). But after a
while it went back to default sort with a header row, which I never do with
this sheet.

Seems like it has a mind of its own.

Thanks again.
 
Back
Top