PDA

View Full Version : Solved: Sort without a title row



Djblois
02-27-2007, 01:34 PM
I am using code to bring up the built in sort dialog. However, I want to bring it up without a header row. Is this possible?

Range(LastCell, "A1").Select
If Not Application.Dialogs(xlDialogSort).Show Then
MsgBox "The Data was not sorted. To Sort Click on the Sort button in the Data Menu"
Range("A2").Select
End
End If

lucas
02-27-2007, 01:50 PM
Daniel, why do you wish to see the dialog? why not just sort it?

Djblois
02-27-2007, 02:18 PM
Want, I have done is create almost like an advanced sort. IT will take into account if the data has a total row or not and also if you have banded your data. It gives the user the options of sorting data with a total row and/ or banded rows anyway the choose. Now I want to add the ability to choose a title row also. I understand they can in the Sort dialog but I am trying to make this as simple as possible for people who don't know excel.

malik641
02-27-2007, 09:51 PM
Check out the sort method in VBA help to understand how I know how many commas to use:

Application.Dialogs(xlDialogSort).Show ,,,,,,,xlNo


That ought to do it! :)

Djblois
02-28-2007, 02:08 PM
malick that is giving me a compile error before I move away from the line of code

malik641
02-28-2007, 07:11 PM
Not sure where you are getting the compile error, but if you are going to use what I gave you in an IF statement then .Show should have parenthesis surrounding the commas and "xlNo". This small example worked for me:
Sub test()
Range("A1:A10").Select

If Not Application.Dialogs(xlDialogSort).Show(, , , , , , , xlNo) Then
MsgBox "The Data was not sorted. To Sort Click on the Sort button in the Data Menu"
Range("A2").Select
End If
End Sub