locked
Sanitizing sheet of resources while maintaining all other fields? RRS feed

  • Question

  • Trying to delete resource names while keeping all other relevant data. When I use this, I get a 1101 error when I try to set T.ActualCost = TempAC. Can someone tell me what I'm missing? Thanks!

    Sub DeleteResources()

     Dim R As Assignment 'Assigned Resource
     Dim T As Task ' Task
     Dim TempD As Long
     Dim TempAC As Double
     Dim TempRC As Double
     Dim TempC As Double


     ' Delete resource assignments.
     For Each T In ActiveProject.Tasks
     TempD = T.Duration
     TempPC = T.PercentComplete
     TempAC = T.ActualCost
     TempRC = T.RemainingCost
     TempC = T.Cost
     For Each R In T.Assignments
     R.Delete
     Next R

     T.Duration = TempD
     T.PercentComplete = TempPC
     T.ActualCost = TempAC
     T.RemainingCost = TempRC
     T.Cost = TempC
     Next T

    End Sub

         
    Monday, October 19, 2020 6:56 PM

All replies

  • Not knowing what Task is (Task is also a class in the .NET Framework) I would think you need to use the New operator.

    In the future use code block and format you code before inserting the code.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, October 19, 2020 11:17 PM
  • Hi rogue844,

    Thank you for posting here.

    >>Trying to delete resource names while keeping all other relevant data.

    Could you provide more detailed description about this sentence?

    In order to help us analyze your question, could you show a complete sample here?

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 20, 2020 7:17 AM
  • Hi Karen, 

    I should've been more clear. Task refers to the task object in MS Project. 

    https://docs.microsoft.com/en-us/office/vba/api/project.task

    Tuesday, October 20, 2020 1:34 PM
  • Ah I see now this is unclear. This refers to a MS Project file and I was aiming to remove the work resources assigned to tasks while maintaining duration, costs, and percent completed. 
    Tuesday, October 20, 2020 1:36 PM
  • Hi rogue844,

    Thanks for your feedback.

    According to the reference you provided, your question is more related to vba, so it will be more appropriate to ask your question in vba forum.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

      

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 21, 2020 1:55 AM