Macro to search through values in a column

Home Forums Microsoft Project Discussion Forum Macro to search through values in a column

Viewing 1 reply thread
  • Author
    • #406361
      Emma Gibney

      I am trying to write a Macro that will search through each entry in a column, Baseline Work, determine if the value is greater than zero and if it is copy the cell to another column. This is what I have now however, it won’t run:

      Sub UpdateWork()
      ‘ Macro Trial
      ‘ Macro Recorded ’16 Nov 15.
      Dim i As Integer
      For i = 1 To 11
      If Cells(i, “Baseline Work”).Value > 0 Then
      SelectTaskField Row:=i, Column:=”Baseline Work”
      SelectTaskField Row:=i, Column:=”Work”
      Next i
      Next i
      End If
      End Sub

      Any help would be appreciated.

    • #406923
      Andy Forrester

      As there has not been any responses yet, I thought I’d post a possible solution.
      Rather than use columns, this code uses tasks [each row in MSP is a display of specific task properties]
      This code will update the task work field WHETHER OR NOT the Work OR the BaselineWork fields are displayed

      ‘Code to update Work field value of project tasks based on Baseline Work field Value
      ‘Assumption being that the Baseline Work value has been set and is > zero
      Sub UpdateWork()
      Dim prj As Project
      Dim tsk As Task

      Set prj = ActiveProject
      For Each tsk In prj.Tasks
      If Not tsk.Summary Then ‘exclude summary tasks
      If Not tsk Is Nothing Then ‘ exclude blank tasks
      If tsk.BaselineWork > 0 Then
      tsk.Work = tsk.BaselineWork
      End If
      End If
      End If
      Next tsk

      Set prj = Nothing
      End Sub

Viewing 1 reply thread
  • You must be logged in to reply to this topic.