Quickly Resetting Flag Fields

J

JJ

I created a code which will reset a particular Flag field to "No" or
False. Currently, it steps through each task individually. Usually
this is pretty fast. However, for large files, it could take several
minutes. Below is a sample of what the code looks like:

Dim allt as tasks
Dim t as task

Set allt = Activeproject. Tasks

For each t in allt
t.Flag1 = False
Next t

Is there a guaranteed faster way?

Thanks in advance!
JJ
 
J

John

JJ said:
I created a code which will reset a particular Flag field to "No" or
False. Currently, it steps through each task individually. Usually
this is pretty fast. However, for large files, it could take several
minutes. Below is a sample of what the code looks like:

Dim allt as tasks
Dim t as task

Set allt = Activeproject. Tasks

For each t in allt
t.Flag1 = False
Next t

Is there a guaranteed faster way?

Thanks in advance!
JJ

JJ,
Guaranteed, wow, you don't want much do you ;-)

You're right, looping through all tasks is not the quickest way to reset
a field. Normally background processing is the fastest but here is a
case where foreground processing is faster. Here's one way to do it.

1. Display the field of interest in the active view. I normally set up a
special view for VBA processing with just that column. That way it
doesn't mess up any normal views which may or may not have that field
shown.
2. Set the value of the field for the first task
3. Use the SelectColumn Method
3. Finally use the FillDown Method

Note: you can also apply a filter using the FilterEdit Method if you
only want to reset a field in a select set of tasks.

Hope this helps.

John
Project MVP
 
J

Jim Aksel [MVP]

Display the Flag column in the view and make sure all tasks are visible.
Highlight the columm by clicking the title.
Hold down the control key, and press Delete. Failure to hold down the
control key while pressing delete will only hide the column. Holding
control will clear the contents.

Alternative: Edit/Clear/Contents.

HTH

Jim
 

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