Beste mensen,
Ik ben al enige tijd bezig met een projectplanning is Excel. op dit forum heb ik al veel hulp gekregen. In principe is het ook een werkbaar document gworrden.
Graag wil ik nog ene kleine aanpassing doen, indien er in kolom 3 "fase" staat wordt er u een rechthoek geplaatst. Graag zou ik die rechthoek aan de uiteinde voorzien van omlaag wijzende driehoekjes (punten)
Ik weet waar het in de macro moet (zie vetgedrukt deel hieronder) maar krijg het niet voor elkaar.
In de bijlage heb ik ze geel gemaakt op regel 9, beveiliging van het werkblad is blanco.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ShpNum As String
ww = ""
Sheets("Projectplanning").Unprotect Password:=ww
'Check if E or F date columns and ignore if not
If Intersect(Target, Range("C8:G300")) Is Nothing Then Exit Sub 'Edit 8 & or 300 if inappropriate
'Check if more than one cell and ignore if yes
If Target.Count > 1 Then Exit Sub
'Otherwise...
r = Target.Row
' ignore if an empty Column C in row
If Cells(r, 7) = "" Then Exit Sub
'otherwise a date has been changed
ShpName = "SHP_" & Cells(r, 7) 'Shape Name
'Delete current shape of that name if it exists
For Each xshape In Shapes
If xshape.TopLeftCell.Row = Target.Row Then xshape.Delete
Next
'get equal date cells
LftCell = Cells(r, 5) + Cells(r, 4) - Cells(6, 5) + 11
RtCell = Cells(r, 6) - Cells(6, 5) + 11
x = Application.Match(Cells(r, 3), Sheets("Gegevens").Columns(5), 0)
If IsNumeric(x) Then fc = RGB(Sheets("Gegevens").Cells(x, 6), Sheets("Gegevens").Cells(x, 7), Sheets("Gegevens").Cells(x, 8))
Select Case Cells(r, 7).Value
Case Is <= 0
'diamond for Milestone date
Set NewShp = ActiveSheet.Shapes.AddShape(msoShapeDiamond, Cells(r, LftCell).Left, Cells(r, LftCell).Top + 2, Cells(r, LftCell).Width, Cells(r, LftCell).Height - 4)
NewShp.Fill.ForeColor.RGB = fc
NewShp.Line.ForeColor.RGB = fc
Case Else
'Get date ranges
Set DtRng = Range(Cells(r, LftCell), Cells(r, RtCell))
LftCell = Cells(r, 5) + Cells(r, 4) + 1 - Cells(6, 5) + 8
RtCell = Cells(r, 6) + Cells(r, 4) + 1 - Cells(r, 5) + 12
'if "fase" in C then add a rectangle
If Cells(r, 3) = "fase" Then
Set NewShp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, DtRng.Left, DtRng.Top + 2, DtRng.Width, DtRng.Height - 10)
NewShp.Fill.ForeColor.RGB = fc
NewShp.Line.ForeColor.RGB = fc 'FormulaLocal = "VERT.ZOEKEN(range(C12:C50);Blad3!E3:I28;5;onwaar)"
Else
'Otherwise if text in C add arrow bar
Set NewShp = ActiveSheet.Shapes.AddShape(msoShapeLeftRightArrow, DtRng.Left, DtRng.Top + 3, DtRng.Width, DtRng.Height - 6)
NewShp.Fill.ForeColor.RGB = fc
NewShp.Line.ForeColor.RGB = fc 'FormulaLocal = "VERT.ZOEKEN(range(C12:C50);Blad3!E3:I28;5;onwaar)"
End If
End Select
'Name shape as per value
NewShp.Name = ShpName
OnlyONEDate:
Sheets("Projectplanning").Protect Password:=ww
End Sub
Ik ben al enige tijd bezig met een projectplanning is Excel. op dit forum heb ik al veel hulp gekregen. In principe is het ook een werkbaar document gworrden.
Graag wil ik nog ene kleine aanpassing doen, indien er in kolom 3 "fase" staat wordt er u een rechthoek geplaatst. Graag zou ik die rechthoek aan de uiteinde voorzien van omlaag wijzende driehoekjes (punten)
Ik weet waar het in de macro moet (zie vetgedrukt deel hieronder) maar krijg het niet voor elkaar.
In de bijlage heb ik ze geel gemaakt op regel 9, beveiliging van het werkblad is blanco.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ShpNum As String
ww = ""
Sheets("Projectplanning").Unprotect Password:=ww
'Check if E or F date columns and ignore if not
If Intersect(Target, Range("C8:G300")) Is Nothing Then Exit Sub 'Edit 8 & or 300 if inappropriate
'Check if more than one cell and ignore if yes
If Target.Count > 1 Then Exit Sub
'Otherwise...
r = Target.Row
' ignore if an empty Column C in row
If Cells(r, 7) = "" Then Exit Sub
'otherwise a date has been changed
ShpName = "SHP_" & Cells(r, 7) 'Shape Name
'Delete current shape of that name if it exists
For Each xshape In Shapes
If xshape.TopLeftCell.Row = Target.Row Then xshape.Delete
Next
'get equal date cells
LftCell = Cells(r, 5) + Cells(r, 4) - Cells(6, 5) + 11
RtCell = Cells(r, 6) - Cells(6, 5) + 11
x = Application.Match(Cells(r, 3), Sheets("Gegevens").Columns(5), 0)
If IsNumeric(x) Then fc = RGB(Sheets("Gegevens").Cells(x, 6), Sheets("Gegevens").Cells(x, 7), Sheets("Gegevens").Cells(x, 8))
Select Case Cells(r, 7).Value
Case Is <= 0
'diamond for Milestone date
Set NewShp = ActiveSheet.Shapes.AddShape(msoShapeDiamond, Cells(r, LftCell).Left, Cells(r, LftCell).Top + 2, Cells(r, LftCell).Width, Cells(r, LftCell).Height - 4)
NewShp.Fill.ForeColor.RGB = fc
NewShp.Line.ForeColor.RGB = fc
Case Else
'Get date ranges
Set DtRng = Range(Cells(r, LftCell), Cells(r, RtCell))
LftCell = Cells(r, 5) + Cells(r, 4) + 1 - Cells(6, 5) + 8
RtCell = Cells(r, 6) + Cells(r, 4) + 1 - Cells(r, 5) + 12
'if "fase" in C then add a rectangle
If Cells(r, 3) = "fase" Then
Set NewShp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, DtRng.Left, DtRng.Top + 2, DtRng.Width, DtRng.Height - 10)
NewShp.Fill.ForeColor.RGB = fc
NewShp.Line.ForeColor.RGB = fc 'FormulaLocal = "VERT.ZOEKEN(range(C12:C50);Blad3!E3:I28;5;onwaar)"
Else
'Otherwise if text in C add arrow bar
Set NewShp = ActiveSheet.Shapes.AddShape(msoShapeLeftRightArrow, DtRng.Left, DtRng.Top + 3, DtRng.Width, DtRng.Height - 6)
NewShp.Fill.ForeColor.RGB = fc
NewShp.Line.ForeColor.RGB = fc 'FormulaLocal = "VERT.ZOEKEN(range(C12:C50);Blad3!E3:I28;5;onwaar)"
End If
End Select
'Name shape as per value
NewShp.Name = ShpName
OnlyONEDate:
Sheets("Projectplanning").Protect Password:=ww
End Sub