Move Triangle Shape based on cell value

Bui Tao

New Member
Joined
Dec 23, 2022
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
I hope someone can help me!

I want that when I enter a value in cell B3 (or B4), the triangle in cell F3 (or J4) moves along. Likewise, when I enter a value in cell C3 (or C4), the triangle in cell J3 (or Q4) will also move. And how to program when I have many TASK to do. It's too hard for me.
Many thanks.
1.PNG
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Not nearly enough there to provide a definitive solution. F'rinstance,
whether or not the numbers in yellow cells correspond to day number;
where's 1 to 19 on the left
will there ever be 3 to 19 on the right
do numbers repeat because every month has (e.g. day 1)
So here's how to center a shape based on row 4 where you have 24/12/2022
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim shp As Shape
Dim i As Integer

If Target.Row = 4 And Target.Column = 10 Then
     i = Day(Cells(4, 10).Value)
     Set rng = ActiveSheet.Range(Cells(4, i - 14), Cells(4, i - 14))
     Set shp = Shapes("5-Point Star 2")
     shp.Left = rng.Left + (rng.Width - shp.Width) / 2
End If

End Sub
NOTE - my date was in J4 so that's why I used 4,10 for cell reference. It would be better to use the target address of the edited cell, but maybe this is a start. It all depends on the unknowns that I listed (and probably more). The Day function may not be relevant. I based it on the assumption that there's some sort of relationship between the numbers in yellow cells with the number of the day.
Not sure how much time I could spend on this given the impending Christmas holidays.
 
Upvote 0
Not nearly enough there to provide a definitive solution. F'rinstance,
whether or not the numbers in yellow cells correspond to day number;
where's 1 to 19 on the left
will there ever be 3 to 19 on the right
do numbers repeat because every month has (e.g. day 1)
So here's how to center a shape based on row 4 where you have 24/12/2022
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim shp As Shape
Dim i As Integer

If Target.Row = 4 And Target.Column = 10 Then
     i = Day(Cells(4, 10).Value)
     Set rng = ActiveSheet.Range(Cells(4, i - 14), Cells(4, i - 14))
     Set shp = Shapes("5-Point Star 2")
     shp.Left = rng.Left + (rng.Width - shp.Width) / 2
End If

End Sub
NOTE - my date was in J4 so that's why I used 4,10 for cell reference. It would be better to use the target address of the edited cell, but maybe this is a start. It all depends on the unknowns that I listed (and probably more). The Day function may not be relevant. I based it on the assumption that there's some sort of relationship between the numbers in yellow cells with the number of the day.
Not sure how much time I could spend on this given the impending Christmas holidays.
Oh, thank you so much. It's great. But I want to now that if I have 10 or 50 TASKS to do. There will be many triangles. How can you program?
 
Upvote 0
Code would have to loop over something - either a set of shapes (and it gets the beginning and ending date values in the rows where the shape is located) or loop over the end and start dates and move the triangles accordingly. I think just about anything is doable, but that doesn't make the task easy. I forgot to mention that when I used Day function result to decide on where to put a shape, it was based on mm/dd/yyyy format, which is not what you are using. What Day returns with your date format would need to be determined IF it in fact, is even relevant. I posted that I wondered about that but so far, still no clarification.

I really think that without a copy of the file, this would take far too many posts to answer all the information that's missing at this point, and there would only be more to come.
 
Upvote 0
Code would have to loop over something - either a set of shapes (and it gets the beginning and ending date values in the rows where the shape is located) or loop over the end and start dates and move the triangles accordingly. I think just about anything is doable, but that doesn't make the task easy. I forgot to mention that when I used Day function result to decide on where to put a shape, it was based on mm/dd/yyyy format, which is not what you are using. What Day returns with your date format would need to be determined IF it in fact, is even relevant. I posted that I wondered about that but so far, still no clarification.

I really think that without a copy of the file, this would take far too many posts to answer all the information that's missing at this point, and there would only be more to come.
Okey, you can access this link to get my file. Help me fix the code if I change the start day or finish day with year is 2023.
Thanks a lot!!
 
Upvote 0
Count of information sought: 4 in post 2
Count of answers I received: 0

I guess you could just edit the If...End If part to work with your sheet, then copy and edit it 10 times for 10 tasks.
if I change the start day or finish day with year is 2023.
I have no idea what that means, or how the year makes any difference IF the number of the day is what matters.
 
Upvote 0
A possible option, via formula, in case the problem is still pending:
-assuming that from F2 and subsequent cells contain the dates
-then set in F4 the formula
Code:
-format F4 with a font size of 20
-copy F4 to the right for as many dates you have in row 2
-copy this line of formulas downward for the expected list of activity

The result will be similar to the attached image, rows 4-6

You might use Wingdings 3 formatting, and obtain the result shown in row 8; in this case the formula in F8 is
[code]=IF(F$2=$B8,"s"&REPT(CHAR(173),3),IF(F$2=$C8,REPT(CHAR(173),3)&"s",IF(AND(F$2>$B8,F$2<$C8),REPT(CHAR(173),8),IF(AND(F$2<=TODAY(),F$2>$B8,$B8<>"",$C8=""),REPT(CHAR(173),7),""))))

(see the image for the real look of line 8)

byBUI TAO-MrEx_C21225_VBA test.xlsm
ABCDEFGHIJKLMNOPQRSTUVW
1TaskStart DayFinish Day2022-dic          2022-dic2023-gen     
2202122232425262728293031010203040506
3Design Mold20/12/202231/12/2022
4Manufacture21/12/202230/12/2022 V____________________________________________V       
5Assemble124/12/2022    V______________________        
6Assemble222/12/202225/12/2022  V______________V            
7Delivery                  
8Task 126/12/202228/12/2022      s s         
9Task 2                  
10Task 3
11Task 4
12Task 5
Sheet1
Cell Formulas
RangeFormula
F1:W1F1=IF(MONTH(F2)<>MONTH(G2),TEXT(F2,"aaaa-mmm"),IF(MONTH(E2)<>MONTH(F2),TEXT(F2,"aaaa-mmm"),""))
G2:W2G2=F2+1
F4:W7F4=IF(F$2=$B4,"V__",IF(F$2=$C4,"__V",IF(AND(F$2>$B4,F$2<$C4),"_____",IF(AND(F$2<=TODAY(),F$2>$B4,$B4<>"",$C4=""),"____",""))))
F8:W8F8=IF(F$2=$B8,"s"&REPT(CHAR(173),3),IF(F$2=$C8,REPT(CHAR(173),3)&"s",IF(AND(F$2>$B8,F$2<$C8),REPT(CHAR(173),8),IF(AND(F$2<=TODAY(),F$2>$B8,$B8<>"",$C8=""),REPT(CHAR(173),7),""))))
F9:W9F9=IF(F$2=$B9,"s4",IF(F$2=$C9,"4s",IF(AND(F$2>$B9,F$2<$C9),4,IF(AND(F$2<=TODAY(),F$2>$B9,$B9<>""),4,""))))
 

Attachments

  • BUI_Immagine 2022-12-29 134709.jpg
    BUI_Immagine 2022-12-29 134709.jpg
    96.8 KB · Views: 17
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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