Website Upgrade Incoming - we're working on a new look (and speed!) standby while we finalise the project

Tips on using this forum..

(1) Explain your problem, don't simply post "This isn't working". What were you doing when you faced the problem? What have you tried to resolve - did you look for a solution using "Search" ? Has it happened just once or several times?

(2) It's also good to get feedback when a solution is found, return to the original post to explain how it was resolved so that more people can also use the results.

VBA - Deleting Tasks (criteria based)

3 replies [Last post]
Rob Garbutt
User offline. Last seen 7 years 1 week ago. Offline
Joined: 2 Aug 2017
Posts: 6
Groups: None

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?

Replies

Rob Garbutt
User offline. Last seen 7 years 1 week ago. Offline
Joined: 2 Aug 2017
Posts: 6
Groups: None

.

Rob Garbutt
User offline. Last seen 7 years 1 week ago. Offline
Joined: 2 Aug 2017
Posts: 6
Groups: None

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

Tom Boyle
User offline. Last seen 10 weeks 6 days ago. Offline
Joined: 28 Nov 2006
Posts: 304
Groups: None

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