Macro to sort project tasks by % Complete gets VB error message

P

Pierre M

I tried to develop a macro to sort project tasks by % Complete. The code is
as follows:
Sort Key1:="% Complete", Renumber:=False

I get the following Microsoft VB error message:
"Compile error: Wrong number of arguments or invalid property assignment"

Can anyone help me out, please?
 
G

Gérard Ducouret

Hi Pierre,

Before running your macro, make sure you are in a Task view, while it'll not
run in a resource view.

Gérard Ducouret
 
J

John

Pierre M said:
Hi Gérard,

Yes, I am in a Task view when the error occurs.

Pierre,
Ok, maybe it would help if we could see a little more of your code. The
snippet you provided looks fine and works fine for me.

John
Project MVP
 
P

Pierre M

Hi John,

I am using Project 2002 and the whole code looks like this:

Sub Sort()
' Macro Sort
' Macro Recorded 02 May '06 by SIGNET\MAGNANPA.
Sort Key1:="% Complete", Ascending1:=False, Key2:="Actual Finish",
Ascending2:=False, Renumber:=False
End Sub
 
R

Rod Gill

Hi,

In Project 2003 it looks like you need Application.Sort which according to
Help is optional!@@!
 
J

John

Rod Gill said:
Hi,

In Project 2003 it looks like you need Application.Sort which according to
Help is optional!@@!

Rod,
Interesting. I did a quick test using Pierre's code verbatim before I
wrote my initial response and I did NOT need the expression. I'm using
Project Pro 2003 SP2. I also tried his "full" code, and everything still
works fine (without the expression). Is it possible that Project 2002
(which Pierre says he is using - but I don't have so I can't try it),
DOES require the expression?

I also wondered if the "NA" in the Actual Finish field might be throwing
a curve, but that doesn't seem to matter either.

John
Project MVP
 
R

Rod Gill

Don't know on this one. My version needed to have application. but the
recorded code did not record it!@#$! I had to add the Application. manually.
 
P

Pierre M

Hi John, Rod, Gerard

I manually entered Application.Sort and in VBE clicked the Run tab and got
another syntax error. I saved the macro anyway then ran it in MSP and it
worked.

Thanks guys
 
J

John

Pierre M said:
Hi John, Rod, Gerard

I manually entered Application.Sort and in VBE clicked the Run tab and got
another syntax error. I saved the macro anyway then ran it in MSP and it
worked.

Thanks guys

Pierre,
See how much fun VBA can be? Glad you got it working.

John
 

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