title: How can I automatically set start date to multiple sequential summary tasks based on the resource allocation?
body: <p>I am trying to use VBA to automatically set the start date of multiple sequential summary tasks (that has no predecessors) based on the resources availability of my project.</p>
  <p>The intention is to optimize the duration of the project, without overalocate an resource.</p>
  <p>I wrote the following code, but it is not perfect yet.</p>
  <pre><code>Sub Test01()
  
  Dim t As Task
  Dim ts As Tasks
  Dim r As Resource
  Dim rs As Resources
  Dim rOver As Integer 'Sum of Overallocated Resources
  Dim hoje As Date
  
  Set ts = ActiveProject.Tasks
  Set rs = ActiveProject.Resources
  
  
  For Each t In ts
  rOver = 1
  hoje = Date
  
          If t.Summary Then
              If t.Predecessors = &quot;&quot; Then
                  Do While rOver &gt; 0
                      t.Start = hoje
                          For Each r In rs
                              If r.Overallocated Then
                              rOver = rOver + 1
                              Else
                              rOver = 0
                              End If
                          Next r
                      hoje = hoje + 1
                      t.Start = hoje
                  Loop
              Else
                  t.Manual = False
              End If
          Else
              t.Manual = False
              
          End If
  Next t
  
  
  End Sub
  
  </code></pre>
  <p>Can someone help me with this challenge?</p>