Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting error 1

Status
Not open for further replies.

skygirl65

Technical User
Jul 18, 2004
32
US
I have spreadsheet with a macro that sorts it alphabetically at the end of the macro. After I made what I believed to be unrelated changes, now the sort does not recognize the headers. For example the lable "last name" is no longer in the header cell, but is replaced by the first entry beginning with A. The lable "last name" is sorted just like an entry. Why is this happening?

 
skygirl65,

Some guesses without a little more information on what how the macro is doing it's work. . .

The data sort command has some preferences -
The headings should have a format applied to them that is different than the rest of the data (it can be as simple as bold, shading, etc). This allows the data sort window to recognize the header row, and leave it out of the sort.

If you changed the formats of the headings it may cause this issue.

Hope this helps.
Samaba
 
skygirl65,

For future reference, please note that macro questions should be posted to forum707, VBA Visual Basic for Applications (Microsoft) Forum.

In the macro, change the line that does the sort to look like the following:
Code:
Selection.Sort Key1:=Range("a2"), Order1:=xlAscending, [!]HEADER:=xlYes[/!]
Right now, the header argument is probably set to xlGuess (if it is declared at all).

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top