Loading...
Quick Links

Macro to search through values in a column

Home Forums Discussion Macro to search through values in a column

  • This topic has 1 reply, 1 voice, and was last updated 4 years ago by Andy Forrester.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #406361 Reply
    Emma Gibney
    Guest

    Hello,
    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”
    EditCopy
    SelectTaskField Row:=i, Column:=”Work”
    EditPaste
    Next i
    Else
    Next i
    End If
    End Sub

    Any help would be appreciated.
    Thanks,
    Emma

    #406923 Reply
    Andy Forrester
    Guest

    Emma,
    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 2 posts - 1 through 2 (of 2 total)
Reply To: Macro to search through values in a column
Your information:




3 + 2 =