data sort not working anymore!

MRA

New Member
Joined
Jun 27, 2008
Messages
36
Hi guys, I have a serious problem here.

I have a large set of data and need to be able to resort it on the fly. I wrote simple code
Code:
Private Sub resortriskplan()

Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Range("A8:J10007").Sort Key1:=Range("B8"), Order1:=xlDescending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
                
Call dblcheckplanning
        
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

That has seemingly been doing the job for a couple weeks now.
I presented it to my boss this morning only to find that the data is not sorting properly! It puts numbers way out of order all over the place! I tried using sort option from the data menu (as opposed to a macro) and it does the same thing!

This is a crucial function of the program, and I need either a solution or a work around of some kind.

Right now I'm working with around 10,000 lines, but I'll ultimately need to have this work for all 40,000 lines Excel will give and then some. My key range is copying from another worksheet in the same book (ie. the key range formula is "=Calculations!xx") and all the values are stored as numbers. I am using Excel 2003.

Thank you all for your help in the past. I'm sorry if I seem harried, it's just really alarming to find that a crucial thing isn't working under deadline. I'm sure you guys know the feeling.
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I've been trying to solve this on my own to no avail. The problem began when I doubled up the lines it is trying to sort.
In Cols C-F I had some data, then I simply doubled them so that Cols C-J contained two sets of the same data.

I worked fine when it was sorting c-f, but stopped working when it was doubled. I tried moving all my duped cols to the end and having them equal the corresponding orig col, then sorting only the orig cols but the same thing happens.

I guess what I'm hoping for from you guys is some insight into how Excel sorts stuff. Am I goofing it somehow by doubling the cols or something along those lines? Or am I just asking too much of my hardware and Excel doesn't understand how to tell me that?

Thanks a bunch guys
Mike
 
Upvote 0
SOLVED​

Ok guys, from trudgin through on my own, I have reaffirmed what could be the oldest axiom we programmers (or at least we amateur programmers) have.

When something is wrong, it's your fault. :p

What was happening was that I was resorting a column that was being used to calculate a column within the same resort. In other words, I was creating a logical loop.

Learn from my mistake, and try not to be such a VBA dummy.
 
Upvote 0

Forum statistics

Threads
1,203,524
Messages
6,055,910
Members
444,834
Latest member
ComputerExcel

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