+ Reply to Thread
Results 1 to 48 of 48

working with shapes

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    working with shapes

    Hi all

    Where do I find a tutorial or examples to show me how to create bars for gantt chart in excel, based on date values?

    Thanks

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: working with shapes

    Hi

    Try having a look at the Peltier Technical Services Inc site on charts. There's a heap of really good chart items there.

    http://peltiertech.com/Excel/Charts/...tml#GanttChart

    rylo

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: working with shapes

    And the home of our very own Excel chart god, http://andypope.info/
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Thanks for the tips but I was thinking about something different. What I had in mind is to create bars directly in a range of cells based on date criteria.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Have a look at in-cell charting
    http://peltiertech.com/Excel/Charts/...ulaCharts.html

    Also look at conditional formatting.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Quote Originally Posted by Andy Pope View Post
    Have a look at in-cell charting
    http://peltiertech.com/Excel/Charts/...ulaCharts.html

    Also look at conditional formatting.
    Thanks for the tip but I already tested those options. What I'm looking for is something similar to project management. I know it can be done in excel because I've seen a few examples in the web.

    I use MS Project for bigger projects, but for some plannings it would be useful to do it directly in excel.

    There must be some tutorial to teach how to do that.

    Greetings

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    As I said you can use conditional formatting.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Quote Originally Posted by Andy Pope View Post
    As I said you can use conditional formatting.
    Hi Andy
    Sorry for insisting, but I didnt present the correct question since the beginning.
    I'm using now conditional formatting based on VBA, for I can have more than 3 options.

    What I would really like to learn is how to built bars based on shapes (rectangules).

    Thanks

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    This will generate the bars using shapes.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Thank you very much Andy

    This is a new beginning for me. Now I'm going to try to adapt this to my file and will show when finished.

    Thank you again

  11. #11
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Hi Andy
    I sent all weekend trying to adapt your code to this file attached. All changes I made didnt go through. They always stopped on error in the code line with match function. My vanity thinking that my very little knowledge would be enough to develop your code.
    Would it be too much begging you to look once to the file?
    For more than one level, is the code look too complex?

    Thank you very much
    Attached Files Attached Files

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Try this. See comments in code
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Hi

    Thank you very much for your help.
    This works almost fine, almost perfect. Some bars dont match with some end dates, but I will try to fix that.
    Other thing I'm going to try is give diferent colors to tasks with diferent levels
    (dreaming awake?)

    I'm learning much more in foruns than the VBA course I took last year

    Thank you very much for your time

    Ioncila

  14. #14
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    I made some little improvements with the code that Andy Pope provided (Thank you very much). But there is 2 or 3 things that I cant solve and I would wish to:

    1. Position of some bars dont match with End date values;

    2. If each column of the timeline represents a week (7 days), Is there a simple way to position the bar in cell range to match with start and end date values?

    3. How to add a new bar showing the task progress (%complete)?

    Maybe this is asking too much but I'm very hopefull to get some help.

    Thank you all and, in particular, thank you very much Andy.

    Here's an attachement
    Attached Files Attached Files

  15. #15
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Andy
    I dont have adjectives to congratulate your work and knowledge.

    Thats exactly what I was looking for.

    Thank you for your sunday time and all the help you provided to me.

    ioncila

  17. #17
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Hi again

    I saw a piece of code from Andy in another thread:

    http://www.excelforum.com/2055217-post4.html

    which can draw shape connectors between 2 cells (I put code in the attached).

    Now, is it possible to convert this connector into something like a predecessor and link 2 or more task bars and show a critical path (see attached)?

    Thank you all
    Attached Files Attached Files

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: working with shapes

    I use MS Project for bigger projects, ...
    You seem to be trying to reinvent Project one piece at a time.

  19. #19
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Quote Originally Posted by shg View Post
    You seem to be trying to reinvent Project one piece at a time.
    Because Excel is so versatile, most of my projects are based on it, except scheduling manegement and other tasks that I thought MSProject was the only and the right way to do it.

    A few months ago, I did realize that Excel could offer, in a light way, some tasks functions of MSProject which are enough to my needs. I simply dont have the knowledge (enough at least) to do the improvements I need. But searching in forums and asking some questions, I did learn so much lately than the years passed.

    Not trying to reinvent anything. You know that when you think if something can be done and you get the answer to that, the next second you are already thinking if it is possible to do another thing and so on.

    However, before posting questions or opening threads, I try harder to make things work out by my own. Unfortunelly, sometimes I cant (specially if it takes to work in VBA).

    Other thing: I dont take any credits for the help I get. In all of my works I post links to forums, threads or people's websites who did provide the improvements I've done in my projects. That's my humble way to thank you all.

    ioncila

  20. #20
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Can you manually add the connectors to illustrate how the numbers in column D should work

  21. #21
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Quote Originally Posted by Andy Pope View Post
    Can you manually add the connectors to illustrate how the numbers in column D should work
    Sorry, is that a question or a suggestion?

  22. #22
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Hi

    It would work as the attached file shows.

    Column "ID" gives the row ID (that can be the real row number and if it is so, this column not necessary) and Column "PREDEC" shows the ID of the task dependency.
    Attached Files Attached Files

  23. #23
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Sorry I can not yet see the logic in your lines.

    Take row 32. Why does the arrow go to 38 instead of 37?

    You already have the code for creating the shape all you need to do is determine the start and finish position

  24. #24
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Quote Originally Posted by Andy Pope View Post
    ...all you need to do is determine the start and finish position
    I cant determine start and finish position of the bars, because of their relative position in each cell, dont know how to create variable for that
    Last edited by ioncila; 04-19-2009 at 06:09 AM.

  25. #25
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    You can set a reference to the shape using this syntax.

    Please Login or Register  to view this content.
    which then allows you to use the Left/Top/width etc properties.

  26. #26
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Hi
    Following your suggestion, I added a piece of code for connectors, but I think it looks confuse or there's something missing

    Please Login or Register  to view this content.

  27. #27
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Just a quick clean up of your code to define the variables.

    Please Login or Register  to view this content.
    The problem is your code is not using any task against which to align the connector.

    Some how your code needs to determine which 2 tasks are relevant for each precedent. You can then use those variables instead of rngA and rngB.

  28. #28
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    So many dificulties to create those variables.
    Is this a step foward? or behind?
    I think my issue is in determinating "varS" and "varE" variables and reading their bar shapes. I leave "rngA" and "rngB" to refer the start and finish of the connector.

    Please Login or Register  to view this content.

  29. #29
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Forget the drawing and sizing of the connector for a moment.

    The tasks you need the code to do are;
    - identify the task where a precedent starts
    - identify the task where a precedent finishes

    can you describe the logic rules for the above. And do those rules actually work for all data sets?

  30. #30
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Thank you very much for still supporting

    I will try to explain the more clearer:

    If you look at the last attached file, I have a "E" column called "ID" and a "G" column called "PREDEC". "ID" may be unnecessary if you consider row number itself as ID for each row (or task).

    So, on "G" I shall indicate the ID of the of the taskbar (or row) where I want the precedent starts. The precedent finishes in the taskbar of the row wich has a value on the correspondent cell in "G".

    Take the example on the attached, please:

    "G22".value=3 - It means thet the precedent should start at row 21 (because value=3 is found in "E21") and should finish at "G22". So, the connector should connect existing bars in row 21 (start) and in row 22 (finish).

    As the example shows, I may need to connect two or more tasks to the same task (see row 32). Again, another precedent should start at row 21 and finish at row 32, and so on.

    I hope this make sense and logical.

    Thank you so much for your interesting, time and help.

  31. #31
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Hi

    I'm trying hard everyday to turn over my dificulties to go through this issue. Unfortunelly, there's something missing in my knowledge (something big, I guess) to step forward.

    May this thread keep on? I don't know, as also I feel I'm pushing too much from the boys here.

    Anyway, thank you for every help and support you gave me.

  32. #32
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Please Login or Register  to view this content.

  33. #33
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Thank you very much for your reply and the code you sent.
    It shows almost the way I wish. However it works "inverted" and dependenciess don't match with the cells we want to.

    As I belive the issue may be in "from" and "to" logic but, i tried to change it, but nothing happens.

    I've attached the workbook where is indicated dependencies created by your code (in black) and in red (those I wish to appear).

    So if you could take a look, it would be nice

    Thanks
    Attached Files Attached Files

  34. #34
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    The arrows are not correct because the bars are not correct.

    Task one has a bar that is called Bar2

    This change of the code will work in your example workbook.
    Please Login or Register  to view this content.

  35. #35
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Thank you very very much. It works just fine, just how I imagine that.

    Before I solve this, a last request please:

    How do you remove existing connectors before update with new values? Here's what I was trying to do:

    Please Login or Register  to view this content.
    Thank you again

  36. #36
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Use the same approach as for the bars.
    When creating the shapes given them a name that you can then use to remove them.

  37. #37
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Thumbs up Re: working with shapes

    What is wrong ?

    Please Login or Register  to view this content.

  38. #38
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    guessing...
    Please Login or Register  to view this content.

    But where in the code are you naming the newly added shape?
    I would create another constant for naming the Connectors to avoid confusion with the bars.

  39. #39
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Sorry but it seems like I'm having a misunderstanding problem. I cant make a relation as you suggest

    Please Login or Register  to view this content.

  40. #40
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    I have added an argument to the build routine that will name the shape.

    In the main routine the loop will delete all shapes with the right name prefix.

    Please Login or Register  to view this content.

  41. #41
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Sorry for the insistance but there is an issue:

    Code stops at

    Please Login or Register  to view this content.
    A msgbox with "Run time error '-2147024809(80070057)': Item with the spcefied name not Found"

  42. #42
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Do the bar shape names match what you are requesting in code.

    Previously we had to add +1 because the bar names started at bar2.
    If you have corrected that problem then it will fall over as the final reference will be to a bar that does not exist.

  43. #43
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    I didnt correct anything because all seemed to work fine after your adding +1.

    The only problem is to erase the existing connectors if I want to update with new values. When I do that the existing connectors remain.

    An information that may be relevant:

    When I run code for taskbars, it executes the update inspite of a msgbox "Run time error '1004':Impossible to obtain Match property of worksheetfunction class (my translation)"

    This happens in the example workbook but works perfectly in my master file (error dont show up)

    Andy: New edit:
    Something strange. I erased manually all shapes and change values once and all code worked fine (except situation for taskbars). Then I changed values again and dependencies worked as wish (delete existing and print new connectors). I've done this a few times. So aparently it seems that is done and solved. I'm going to experiment in my master file and then I'll give you feedback.
    Last edited by ioncila; 05-06-2009 at 12:38 PM.

  44. #44
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    So I did experience for code in my master file:

    1. Didn't work at once. I tried some changes to find out what was wrong and, after taking off that "+1" you added, it worked fine.

    2. Then I merged code for bars and for connectors, all in one module. I began to have some troubles with the match function and with shapes properties. Sometimes it works, sometimes not. Once it shows an error type and then shows another

    3. I added then "On Error Resume Next" on top of code and after that everything seems to work fine. I changed values and updated a dozen times and no more problems.

    But I feel some instability. Did that "On Error Statement" solve those problems and make code run well from now on or do I need to look deeply?
    Last edited by ioncila; 05-07-2009 at 06:21 PM.

  45. #45
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    Indeed the On Error Resume is doing exactly what it says.

    When the error occurs continune. So adding that line has not fixed the error it has simply masked it.

  46. #46
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: working with shapes

    Ok The error still there (masked, as you say). But the updates work well and with no calculating errors (with On Error Resume). How can it be? Will it work "trustly" like this from now on?

    And, since both workbooks (example wb and master wb) have same structure, is there a logic explanation for different performances (example needs "+1" added and master not)?

    Sorry if I put many questions.

    Thanks

  47. #47
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: working with shapes

    I can not tell whether the code, with error checking, will work in all cases.

    As I said the problem is caused by trying to reference a shape by name that does not exist. The root of your problem is that bars are/where created that are out of sequence with the task id.

  48. #48
    Registered User
    Join Date
    10-04-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: working with shapes

    Hi Sirs,

    Good Day,

    I've been spending some time to adapt my excel on the code provided by Andy and failing continuously. Appreciate if you could help me work with this please.cable pulling_edited_MACRO_1.xlsm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1