Adding shapes to denote milestones based on cell reference?

Joined
Jul 27, 2017
Messages
24
Hi all,

I have created a large Gantt chart in excel (through formulas, not as a chart). I have 2 additions I am trying to make to my sheet in order for it to be functional:
  1. Adding in a date line for today - a red, bold border line that lines up with today's date
  2. Adding in a shape (5-point star) on the dates that are called out as being a milestone date

I have yet to figure out how to add the line for the current date, but I was hoping someone could help me with adding in the 5-point stars to the cells that are identified as milestone dates.

This link shows what my document currently looks like: link
Ideally, I'd like to assign a macro to the "Add Milestones" shape and have it create 5-point stars on the corresponding End Date for any row where column C is populated with a "Yes".
ebm7Fx


Currently, I have the following code written in to attempt to add these shapes, but somewhere in my code is an issue that is causing it to not function at all. My exposure to writing/editing this code is severely limited, so I was hoping someone here could provide some assistance or point me in the right direction.

Code:
Sub DoIt()

Dim rngStart As Range
Dim r As Long
Dim dte1 As Date
Dim rngToFind As Range
Dim sh As Shape
Dim sngLeft As Single
Dim sngTop As Single
Dim sngHeight As Single
Dim sngWidth As Single
'remove all shapes
For Each sh In ActiveSheet.Shapes
    If Left(sh.Name, 7) = "5-Point" Then
        sh.Delete
    End If
Next
Set rngStart = ActiveSheet.Range("A7")
r = 1
Do While rngStart.Offset(r, 0) <> ""
    If rngStart.Offset(r, 2) = "Yes" Then
        dte1 = rngStart.Offset(r, 4)
        Set rngToFind = ActiveSheet.Rows("5:5").Find(what:=dte1)
        If Not rngToFind Is Nothing Then
            sngWidth = 15
            sngHeight = 15
            sngLeft = rngToFind.Left + rngToFind.Width / 2 - sngWidth / 2
            sngTop = rngStart.Offset(r, 0).Top + rngStart.Offset(r, 2).Height / 2 - sngHeight / 2
            ActiveSheet.Shapes.AddShape(msoShape5pointStar, sngLeft, sngTop, sngWidth, sngHeight).Select
        Else
            MsgBox "End Date not found in top row"
        End If
    End If
    r = r + 1
Loop
Range("A7").Select
End Sub

Thank you in advance!!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Have you considered using wingding or webding characters in a formula inside the cell?
=IF(AND(C4="Yes",NOW()-E4>14),"«","")
Column C is Yes. Date is 14 days past or greater.
Character "«" is a 5 point star in Wingdings font

Add a new column next to the End Date and add that formula

Just a thought :)
 
Upvote 0
Hi Jeff, so your formula works great, really inventive idea on how to get a shape into a cell without having to use any fancy code. My issue is that I want to have this milestone shape (so the 5-point star) show up in the corresponding column that is associated with the date listed in column E. For example, my sheet looks like the following:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Milestone?[/TD]
[TD]End Date[/TD]
[TD][/TD]
[TD]4/20/18[/TD]
[TD]4/21/18[/TD]
[TD]4/22/18[/TD]
[TD]4/23/18[/TD]
[TD]4/24/18[/TD]
[/TR]
[TR]
[TD]Yes[/TD]
[TD]4/22/18[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][5-point star][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]4/23/18[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

So in this example, I'd want a 5-point star to show up in cell F2 (the one denoted with the "[5-point star]"). Any ideas on how to modify your formula to make that possible?

Thanks!
 
Upvote 0
Assuming Milestone header is in cell A1
put this in cell D2 and copy to the rest of the dates
=IF(AND($A2="Yes",D$1=$B2),"«","")
 
Upvote 0
Maybe for the Red line issue you could use conditional formatting.

Highlight the range D2:N100
Start a new Conditional formatting rule based a Formula
Use this formula: =D$1<$B2
format the cell with a fill affect. Color 1 is white. Color 2 is red. Horizontal Shading style. Bottom left variant which puts the red in the middle.

Now you have red cells to the left of each milestone.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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