Need to use VBA to create a Gantt chart

SeanOB

New Member
Joined
Jul 16, 2017
Messages
1
Hi

First post, so please excuse if added items/references wrong.
I am trying to develop a Gantt using VBA, I cannot use the Conditional Fromatting style or any style that prevents me from referencing the date cells which have colour or text.
I would like to have two sheets. Sheet 1 = Gantt and sheet 2 will have a lookup for specific engineer.
My initial thought is to create a gantt ffrom which I can Index match (or similar, perhaps even use VBA again) and populate the date ranges booked in sheet one against each engineers name in sheet 2
Code I have used so far seems to hang Excel, but if I add "Stop" before "End Sub " it does both colour and add text.
Any assistance would be appreciated.

CODE:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim i, j As Integer

ScreenUpdating = False

On Error Resume Next
FirstRow = Sheets("Sheet1").Usedrange.Rows(2).Row
LastRow = Sheets("Sheet1").Usedrange.Rows(ActiveSheet.Usedrange.Rows.Count).Row
LastCol = Sheets("Sheet1").Usedrange.Columns(ActiveSheet.Usedrange.Columns.Count).Column

With Sheets("Sheet1")
For j = 5 To LastCol
For i = 2 To LastRow

If Sheets("Sheet1").Application.WorksheetFunction.IsText(Cells(i, 1)) = True And Cells(1, j).Value >= Cells(i, 3).Value And Cells(1, j).Value <= Cells(i, 4).Value Then
Sheets("Sheet1").Usedrange.Cells(i, j).Value = Cells(i, 2)
Sheets("Sheet1").Usedrange.Cells(i, j).Interior.ColorIndex = 4

End If
Next
Next
End With

ScreenUpdating = True

End Sub


Sheet 2
ENGINEER21/01/201722/01/201723/01/201724/01/201725/01/201726/01/201727/01/201728/01/201729/01/201730/01/201731/01/201701/02/201702/02/2017
Engineer 1ADADADWDWD
Engineer 2A3A3A3A3A3A3A3
Engineer 3A4A4A4A4A4A4A4A4
Engineer 4A5A5A5A5A5A5A5A5A5
Engineer 5A6A6A6A6A6A6A6A6A6A6
Engineer 6A7A7A7A7A7A7A7A7A7A7A7
Engineer 7A9A9A9A9A9A9A9A9A9A9A9A9

<tbody>
</tbody>













Sheet 1
ENGINEERPROJECTSTART DATEEND DATE21/01/201722/01/201723/01/201724/01/201725/01/201726/01/201727/01/201728/01/201729/01/201730/01/201731/01/201701/02/201702/02/2017
Engineer 1WD24/01/201726/01/2017ADADAD
Engineer 1WD25/01/201726/01/2017WDWD
Engineer 2A321/01/201727/01/2017A3A3A3A3A3A3A3
Engineer 3A421/01/201728/01/2017A4A4A4A4A4A4A4A4
Engineer 4A521/01/201729/01/2017A5A5A5A5A5A5A5A5A5
Engineer 5A621/01/201730/01/2017A6A6A6A6A6A6A6A6A6A6
Engineer 6A721/01/201731/01/2017A7A7A7A7A7A7A7A7A7A7A7
Engineer 7A921/01/201701/02/2017A9A9A9A9A9A9A9A9A9A9A9A9

<tbody>
</tbody>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,560
Messages
6,125,527
Members
449,236
Latest member
Afua

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top