SORT

navyaa

Board Regular
Joined
Jul 7, 2002
Messages
223
I have a macro which sorts a range but when the range is empty or for some other reason it gives an error. Is there anyway i can make this work..I am pasting the code below:

Application.Goto Reference:="DTHSORT2"
Range(ActiveCell, ActiveCell.Offset([SETCNT].Value, 0)).Select
ActiveWorkbook.Names.Add Name:="REPORTED", RefersToR1C1:=Selection
Application.Goto Reference:="REPORTED"
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.Goto Reference:="DATES"
Selection.Sort Key1:=Range("B1"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Any Suggestions?

Any help would be very appriciated....
Thank you,
Navya
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
You can add "error handling" to handle the error. Before that section of code, if you put a line in that says "On Error Resume Next", it will skip over any error and go to the next line. Then, after the sort code, you can type in "On Error Goto 0" to reset the code so it won't skip any other errors further on down the line.

If you don't want to skip all the errors, but just one error type, you can use error handling to "capture" the particular error and decide how you want to handle it (i.e. use the "Resume Next" command or print a message). Go to the following web-site for information on error handling:

http://www.barasch.com/excel/vba-errors.htm

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,203,605
Messages
6,056,251
Members
444,853
Latest member
sam69

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top