Sort problem - perplexing and annoying in the extreme

B

Brett

Hello out there. I have a line of code to sort a range that has only pasted
values in it, there are no formulas whatsoever.
F_REF.Range("AA54:AE72").Sort Key1:=F_REF.Range("AE72"), _
Order1:=xlAscending, Key2:=F_REF.Range("AB72"), Order1:=xlAscending

F_REF has previously been set to the sheet name.

Now sometimes this line of code works, and sometimes it doesn't (at the
moment it has decided not to work at all). Normally, for this macro, I have
calculation off, but in debugging I have tried calc to auto and it doesn't
make any difference (and nor should it, because they are values only).

What is particularly aggravating about this "non-sorting" is that it ALWAYS
works if I either execute the line by stepping through the code, or if I run
a little stand-alone macro that executes the sorting macro.

How can this possibly be please? Regards, Brett
 
B

Brett

In the interim I've spotted a couple of things in the line of code. I hadn't
specified Order2 for the second key, and both keys were set to the last row
rather than the first (AE72 should be AE54 et al). HOWEVER, that still
doesn't explain why it works when it's done manually, which means that I'm
still looking for an explanation of what might be going on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top