Skip to content

VBA - Deleting Tasks (criteria based)

Rob GarbuttMember for 9 years 2 months
Created
3
3
0

Hi all, I'm looking for some help using VBA to delete rows in an MSP I own. There aretasks in my plan labelled as either "C" or "I" (as in Client or Internal) using a custom "text23" column. I'm currently having to manually delete, line by line those labelled "I" in order to send my client a sanitised version of the plan.

 

I'm not quite at the stage yet to write my own VBA, but I'm certainly able to administer it. does anyone have an idea as to how the code to perform this task should look?

3 replies

Oldest first
  1. 0
    Tom Boyle ·

    Hi Rob,Here's a simple

    Hi Rob,

    Here's a simple procedure that does what you suggest for a simple project I tested it on.

    Sub DeleteInternal()

    Dim t As Task

        For Each t In ActiveProject.Tasks

            If Not t Is Nothing Then

                If t.Text23 = "I" Then t.Delete

            End If

        Next t

    End Sub

     

     

     
    Personally I would never use this kind of hammer on one of my schedules - without very serious review and confirmation of the "I" codes.  You are liable to break some logical or resource link, and the client will not be happy when they open your schedule, calculate it, and get different results than you have.
     
    You might also consider developing a routine that simply obfuscates the names of the tasks, leaving the logic and other data untouched.
     
    Good luck, tom
  2. 0
    Rob Garbutt ·

    .

    .

  3. 0
    Rob Garbutt ·

    Thanks Tom, this is really

    Thanks Tom, this is really useful.  Strangely I appear to have to run the macro a couple of times in order to delete all "I" tasks, but it beats doing it manually that's for sure! (my plan is 5k tasks long).

    Also I agree with your advice regarding this method being slightly risky, and in all honesty I don't see any reason to hide anything from the client anyway, but I aint the boss!  Ultimately I'm untertaking this task manually regardless, so I've ensured that no logic will be broken in the process, and now it's automated it can be done much quicker!

    Thanks again,

    Rob

Log in or join to reply

ProjectControls.com is free to join. Members can post questions, reply, vote and follow discussions.

Existing members: your original username and password still work. Forgot password?