Hi
I´m very very new in vba and i´ve made this code to run a sort of gantt chart for some projects of my own. But this macro takes about 5 minutes to run. I've search on the web for faster methods but no luck. I think the problem is in the syntax of the code. So i wish i could get some help. Thank you very much. I use Excel 2003.

Here's the code:

[VBA]
'EXECUTAR GRÁFICO GANTT
Sub GanttChart()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

Dim ws As Worksheet
Set ws = Worksheets("PT Geral1463d")

'Gráfico Gantt
ws.Range("O21:HN494").Select
With Selection
Interior.ColorIndex = xlNone
Borders(xlDiagonalDown).LineStyle = xlNone
Borders(xlDiagonalUp).LineStyle = xlNone
Borders(xlEdgeTop).LineStyle = xlNone
Borders(xlEdgeBottom).LineStyle = xlNone
Borders(xlInsideHorizontal).LineStyle = xlNone
End With

Dim i As Integer
Dim c As Integer
Dim Sdate As Date
Dim Edate As Date

For i = 21 To 494
For c = 15 To 222

If Cells(i, 4).Value > 0 And (Cells(5, c).Value >= Cells(i, 10).Value Or _
Cells(6, c).Value >= Cells(i, 10).Value Or _
Cells(7, c).Value >= Cells(i, 10).Value Or _
Cells(8, c).Value >= Cells(i, 10).Value Or _
Cells(9, c).Value >= Cells(i, 10).Value Or _
Cells(10, c).Value >= Cells(i, 10).Value Or _
Cells(11, c).Value >= Cells(i, 10).Value) And (Cells(5, c).Value <= Cells(i, 11).Value Or _
Cells(6, c).Value <= Cells(i, 11).Value Or _
Cells(7, c).Value <= Cells(i, 11).Value Or _
Cells(8, c).Value <= Cells(i, 11).Value Or _
Cells(9, c).Value <= Cells(i, 11).Value Or _
Cells(10, c).Value <= Cells(i, 11).Value Or _
Cells(11, c).Value <= Cells(i, 11).Value) Then

Select Case Cells(i, 4)
Case 1
Cells(i, 4) = 1
Cells(i, c).Interior.ColorIndex = 11
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 11
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 11
.Weight = xlThin
End With
With Cells(i, c).Characters.Font
.ColorIndex = 11
End With
Case 2
Cells(i, 4) = 2
Cells(i, c).Interior.ColorIndex = 41
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 41
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 41
.Weight = xlThin
End With
With Cells(i, c).Characters.Font
.ColorIndex = 41
End With
Case 3
Cells(i, 4) = 3
Cells(i, c).Interior.ColorIndex = 37
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 37
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 37
.Weight = xlThin
End With
With Cells(i, c).Characters.Font
.ColorIndex = 37
End With
Case 4
Cells(i, 4) = 4
Cells(i, c).Interior.ColorIndex = 24
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 24
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 24
.Weight = xlThin
End With
With Cells(i, c).Characters.Font
.ColorIndex = 24
End With
End Select
End If
Next c
Next i

'Equipamento
ws.Range("O503:HN689").Select
With Selection
Interior.ColorIndex = xlNone
Borders(xlDiagonalDown).LineStyle = xlNone
Borders(xlDiagonalUp).LineStyle = xlNone
Borders(xlEdgeTop).LineStyle = xlNone
Borders(xlEdgeBottom).LineStyle = xlNone
Borders(xlInsideHorizontal).LineStyle = xlNone
End With

For i = 503 To 689
For c = 15 To 222

If Cells(i, 4).Value > 0 And (Cells(5, c).Value >= Cells(i, 10).Value Or _
Cells(6, c).Value >= Cells(i, 10).Value Or _
Cells(7, c).Value >= Cells(i, 10).Value Or _
Cells(8, c).Value >= Cells(i, 10).Value Or _
Cells(9, c).Value >= Cells(i, 10).Value Or _
Cells(10, c).Value >= Cells(i, 10).Value Or _
Cells(11, c).Value >= Cells(i, 10).Value) And (Cells(5, c).Value <= Cells(i, 11).Value Or _
Cells(6, c).Value <= Cells(i, 11).Value Or _
Cells(7, c).Value <= Cells(i, 11).Value Or _
Cells(8, c).Value <= Cells(i, 11).Value Or _
Cells(9, c).Value <= Cells(i, 11).Value Or _
Cells(10, c).Value <= Cells(i, 11).Value Or _
Cells(11, c).Value <= Cells(i, 11).Value) Then

Select Case Cells(i, 4)
Case 1
Cells(i, 4) = 1
Cells(i, c).Interior.ColorIndex = 11
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 11
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 11
.Weight = xlThin
End With
Case 2
Cells(i, 4) = 2
Cells(i, c).Interior.ColorIndex = 41
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 41
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 41
.Weight = xlThin
End With
Case 3
Cells(i, 4) = 3
Cells(i, c).Interior.ColorIndex = 37
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 37
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 37
.Weight = xlThin
End With
Case 4
Cells(i, 4) = 4
Cells(i, c).Interior.ColorIndex = 24
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 24
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 24
.Weight = xlThin
End With
'With Cells(i, c).Characters.Font
'.ColorIndex = 24
'End With
End Select
End If
Next c
Next i

'Mão de Obra
ws.Range("O692:HN717").Select
With Selection
Interior.ColorIndex = xlNone
Borders(xlDiagonalDown).LineStyle = xlNone
Borders(xlDiagonalUp).LineStyle = xlNone
Borders(xlEdgeTop).LineStyle = xlNone
Borders(xlEdgeBottom).LineStyle = xlNone
Borders(xlInsideHorizontal).LineStyle = xlNone
End With

For i = 692 To 717
For c = 15 To 222

If Cells(i, 4).Value > 0 And (Cells(5, c).Value >= Cells(i, 10).Value Or _
Cells(6, c).Value >= Cells(i, 10).Value Or _
Cells(7, c).Value >= Cells(i, 10).Value Or _
Cells(8, c).Value >= Cells(i, 10).Value Or _
Cells(9, c).Value >= Cells(i, 10).Value Or _
Cells(10, c).Value >= Cells(i, 10).Value Or _
Cells(11, c).Value >= Cells(i, 10).Value) And (Cells(5, c).Value <= Cells(i, 11).Value Or _
Cells(6, c).Value <= Cells(i, 11).Value Or _
Cells(7, c).Value <= Cells(i, 11).Value Or _
Cells(8, c).Value <= Cells(i, 11).Value Or _
Cells(9, c).Value <= Cells(i, 11).Value Or _
Cells(10, c).Value <= Cells(i, 11).Value Or _
Cells(11, c).Value <= Cells(i, 11).Value) Then

Select Case Cells(i, 4)
Case 1
Cells(i, 4) = 1
Cells(i, c).Interior.ColorIndex = 11
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 11
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 11
.Weight = xlThin
End With
Case 2
Cells(i, 4) = 2
Cells(i, c).Interior.ColorIndex = 41
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 41
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 41
.Weight = xlThin
End With
Case 3
Cells(i, 4) = 3
Cells(i, c).Interior.ColorIndex = 37
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 37
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 37
.Weight = xlThin
End With
Case 4
Cells(i, 4) = 4
Cells(i, c).Interior.ColorIndex = 24
With Cells(i, c).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 2
.Weight = xlThick
End With
With Cells(i, c).Borders(xlRight)
.LineStyle = xlContinuous
.ColorIndex = 24
.Weight = xlThin
End With
With Cells(i, c).Borders(xlLeft)
.LineStyle = xlContinuous
.ColorIndex = 24
.Weight = xlThin
End With

End Select
End If
Next c
Next i

Set ws = Nothing

Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub
[/VBA]