Filter return count

E

EarlePearce

I apply resource filters & print via code but some return no tasks and
errors. I need to find a way in code to check for filter results returning
no tasks.

Earle
 
J

John

EarlePearce said:
I apply resource filters & print via code but some return no tasks and
errors. I need to find a way in code to check for filter results returning
no tasks.

Earle

Earle,
There are a couple of ways to do it. I've use both methods in various
macros.

SelectTaskColumn
On Error Resume Next
Set Area = ActiveSelection.Tasks
If Err > 0 Then
[message saying no tasks were filtered]
End
Else
[process normally]
On Error GoTo 0 'clears error
End If

or

SelectTaskColumn
If ActiveSelection > 0 Then
[process normally]
Else
[message saying no tasks were filtered]
End If

Hope this helps.
John
Project MVP
 
M

Mike Glen

Hi Earle,

Try posting on the developer newsgroup. Please see FAQ Item: 24. Project
Newsgroups. FAQs, companion products and other useful Project information
can be seen at this web address: http://project.mvps.org/faqs.htm

Mike Glen
Project MVP
 
E

EarlePearce

Thanks, that was it. I kept trying to force activeselection.count or
something similiar. Getting forgetful.

John said:
EarlePearce said:
I apply resource filters & print via code but some return no tasks and
errors. I need to find a way in code to check for filter results returning
no tasks.

Earle

Earle,
There are a couple of ways to do it. I've use both methods in various
macros.

SelectTaskColumn
On Error Resume Next
Set Area = ActiveSelection.Tasks
If Err > 0 Then
[message saying no tasks were filtered]
End
Else
[process normally]
On Error GoTo 0 'clears error
End If

or

SelectTaskColumn
If ActiveSelection > 0 Then
[process normally]
Else
[message saying no tasks were filtered]
End If

Hope this helps.
John
Project MVP
 
J

John

EarlePearce said:
Thanks, that was it. I kept trying to force activeselection.count or
something similiar. Getting forgetful.

EarlePearce,
You're welcome and thanks for the feedback.

Mike is correct in that questions on VBA really should be posted to our
developer newsgroup. I and a few others will generally answer the
simpler VBA issues in this newsgroup but the preferred posting is in the
other group.

John
John said:
EarlePearce said:
I apply resource filters & print via code but some return no tasks and
errors. I need to find a way in code to check for filter results
returning
no tasks.

Earle

Earle,
There are a couple of ways to do it. I've use both methods in various
macros.

SelectTaskColumn
On Error Resume Next
Set Area = ActiveSelection.Tasks
If Err > 0 Then
[message saying no tasks were filtered]
End
Else
[process normally]
On Error GoTo 0 'clears error
End If

or

SelectTaskColumn
If ActiveSelection > 0 Then
[process normally]
Else
[message saying no tasks were filtered]
End If

Hope this helps.
John
Project MVP
 

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