View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Class Modules - referring to workbook properties

Seems reasonable to me, sorting is a visual thing. Just like a date of
10-Dec-2009 is the visual form of a date number, data on a spreadsheet is
the visual form of the underlying values. If it is hidden, it is for a
reason, so presumably shouldn't be messed with. Anyway, the resolution is so
simple.

I don't like Thai food. I love curry, but not Thai curry. I find it too
sickly sweet.


--
__________________________________
HTH

Bob

"Brett" wrote in message
...
Hi Bob, yes, F_REF is a sheet, and that reference is used several times
before the sort. What I'm saying is that if I put a breakpoint on the sort
and then press F8 to step through the code it works. Now then, since I
sent
my original Q to you this morning (Sydney time) I've discovered the most
bizarre thing. If the cells that are being sorted are hidden then the sort
fails. If they are not hidden it works (with the automatic macro as well).
When I was stepping through the code I had the rows/cols unhidden so that
I
could see what was going on (with a split screen) and was thus able to
detirmine that the code actually does work in "manual". Of course every
time
it runs on auto the cells are hidden, and that's when it fails.

So, to counteract this problem what I have to do is unhide rows/cols
before
the sort and then re-hide, and it works every time.That's not normal
behaviour is it? I mean, for crying out loud, you have to be able to sort
a
hidden range, especially given that you can select a hidden range.

Just to clarify, when I run it manually I'm not using other lines of
code -
they are the very same lines, not even copied to somewhere else.

BTW, a) the curry was good, b) my partner tracked the mohican cartoon on
YouTube at
http://www.youtube.com/watch?v=bHCpdXsn-NY
I hadn't seen it for years.



"Bob Phillips" wrote:

Brett,

I normally find that when things work manually but not automatically it
is
down to objects that are not fully qualified, because I select the sheet
or
whatever when stepping it.

But, assuming that F_REF is a worksheet object, your code looks fully
qualified so it would not appear to be the problem.

Without the context, it is hard to offer any other advice.

--
__________________________________
HTH

Bob

"Brett" wrote in message
...
Hi Bob

I posted a question yesterday but haven't had any takers, and now it's
becomng urgent (it's the last problem to vercome before I go live).

I have the following line in a macro:

F_REF.Range("Y54:AE72").Sort Key1:=F_REF.Range("AE54"),
Order1:=xlAscending,
Key2:=F_REF.Range("AB54"), Order2:=xlAscending, _
Header:=xlNo, OrderCustom:=1,
MatchCase:=False,
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal

Most often when this line is run automatically, it doesn't sort, but
there
are times when it does (rare). If I step through the code then the sort
works
EVERY time. Similarly, if I execute the macro manually by clicking a
text
box, it works every time.

I've tried it with calc Auto/Manual and it makes no difference
whatsoever.

I am at a complete loss with this. I cannot understand how it can work
manually but not as part of a macro that runs it automatically.

I am working with the same test data set in every instance (i.e. when
it
works and when it doesn't). Do you have any idea what could be causing
this,
and if not how I could work around it please?

I've tried putting just the sort line into a separate macro, and that
worked
for a little while, but now that too fails to work ( I thought I had
it
licked with a work-around but not to be). Regards, Brett