VB MACRO Assistance

Author Message
dave_m13

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 10/13/2011
  • Status: offline
VB MACRO Assistance Thursday, October 13, 2011 2:18 AM (permalink)
0
Hi All
 
I have never used VB before but have this Macro that I need to try and amend. I wonder whether anyone would be so kind in assisting me, I am not even sure this is the correct place.
 
The script is below, What I would like it to do is if the text4, text5 and text6 fields are empty then run the macro, if they are not empty ignore the script and move onto the next empty task field and populate with the next sequential number.
 
Many Thanks
Dave
 
Sub SetFields()
    ' You MUST EDIT the next three lines before running this macro
    Const sncProject = "PRJ0010009"
    Const sncTaskNumPrefix = "PRJTASK"
    Const sncTaskNumBase = 10000
    Dim t As Task
    Dim pred As Task
    Dim order As Integer
    For Each t In ActiveProject.Tasks
        t.SetField pjTaskText4, sncProject
        t.SetField pjTaskText7, "Pending"
        t.SetField pjTaskText5, sncTaskNumPrefix & Format(sncTaskNumBase + t.ID, "00000")
        If t.OutlineLevel > 1 Then
            t.SetField pjTaskText6, t.OutlineParent.Text5
        Else
            t.SetField pjTaskText6, sncProject
        End If
        order = 0
        t.SetField pjTaskMarked, "No"
        For Each pred In t.PredecessorTasks
            If pred.OutlineParent <> t.OutlineParent Then
                ' Only sibling dependencies can be imported into SNC.
                ' Flag this row as a problem and ignore the dependency.
                t.SetField pjTaskMarked, "Yes"
            Else
                If pred.Number7 > order Then
                    order = pred.Number7
                End If
            End If
            Next pred
        t.SetField pjTaskNumber7, order + 10
    Next t
End Sub
 
#1
    Wakawaka

    • Total Posts : 456
    • Scores: 23
    • Reward points : 0
    • Joined: 8/27/2009
    • Status: offline
    Re:VB MACRO Assistance Sunday, October 16, 2011 2:07 PM (permalink)
    0
    The best way to check the values would be checking the length of the string.
     
     If Len(text4.Value) <> 0 And Len(text5.Value) <> 0 And Len(text6.Value) <> 0 Then 'The fields are NOT null or empty; do something End If 

     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9