+ Reply to Thread
Results 1 to 18 of 18

change triangle size by cell inputs

  1. #1
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    change triangle size by cell inputs

    i want to change the size of a triangle as I changed the values in cell.i want its position(coordinates) remains the same.corner of rectangle or any cell.

    sheets attached for reference
    Attached Files Attached Files
    Last edited by riz4u; 04-09-2016 at 02:59 AM.

  2. #2
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Re: change triangle size by cell inputs

    Try with the code below. Place it in the sheet where you have the shapes (not in the Workbook or Module).

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: change triangle size by cell inputs

    Or
    Put this code in the sheet module

    (open attached file and then amend the values - size changes automatically)

    Please Login or Register  to view this content.
    Easy to modify for more shapes
    Attached Files Attached Files
    Last edited by Kevin#; 04-08-2016 at 07:24 AM.
    If a response has helped then please consider rating it by clicking on *Add Reputation below the post
    When your issue has been resolved don't forget to mark the thread SOLVED (click Thread Tools at top of thread)

  4. #4
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    THANKS FOR HELP,

    only one problem left its change his position from corner to some where else.i want its grows from corner.from corner increase or decrease his size.problem2.png

  5. #5
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    thanks,
    your code working nicely but only problem left it change its coodinate,i want its grows with same position,please view picture attached.
    small triangle when i changed size its grows to big but didnt change its coorproblem2.pngdinates.

  6. #6
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    thanks,
    your code working nicely but only problem left it change its coodinate,i want its grows with same position,please view picture attached.
    small triangle when i changed size its grows to big but didnt change its coorAttachment 455121dinates.

  7. #7
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Re: change triangle size by cell inputs

    I don't think (or at least i don't know how) is possible to anchor excel object to fixed position, and still have the flexibility to change it based on cell input.

  8. #8
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: change triangle size by cell inputs

    @riz4u
    Mathematically possible I am sure, but tricky!

    - when you select a shape, even if it is a triangle, it sits inside a rectangle
    - when you add a shape its position is determined by the co-ordinates of the top left corner of the rectangle
    - when you add an isosceles triangle, the top left corner is above the left corner of the triangle, and opposite the top of the triangle
    - a rectangle has 4 corners, 2 of which will always marry up with 2 corners of an isosceles triangle - but which 2?
    - you have rotated all the triangles
    - which corner of the triangle should have a fixed co-ordinate?

    Ignoring excel for 1 minute, can you provide a mathematical formula to determine the co-ordinates of the each corner of the rectangle based on the co-ordinates and size of the triangle?

  9. #9
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    dear please forget the rectangle,try to stick triangle with any cell.i tried wil cell.top and left vlaues but still its change its coordiantes.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: change triangle size by cell inputs

    Please continue your questions on this thread. I have closed your other new thread regarding this question
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  11. #11
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: change triangle size by cell inputs

    You will not fix your problem without fairly complex maths.
    The problem is there because the shapes have been rotated.
    Unfortunately, when Excel rotates a shape, Excel retains the original "Left" and "Top" values, and rotates the shape around a "fixed point"
    When a shape is resized, it still retains those same "Top" & "left" values, but of course everything else has changed which is why the shape moves - it is still referring to those original values.

    To tell Excel where to put a shape after we have resized it we need to calculate where to move it relative to those original values.
    This link may help you understand the calculations required.

    The only way that it might be possible is by attaching the shape to a cell and using the co-ordinates of the cells themselves - but even that is not as easy as it sounds because (as you have already discovered) the shapes will still move when re-sized! I will investigate this in a few days and update the thread after that.

    Another possibility would be to create an image (outside of excel) and save 4 versions (0, 90, 180, 270 degree rotations). Then there would be zero rotation within excel, only a resize. (note - it is not possible create a new "Shape" for Excel).
    Last edited by Kevin#; 04-09-2016 at 09:46 AM.

  12. #12
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    dear, i change something instead of increase and decrease size ,i used misc shape and called them from cell A1,only one problem left how to call out more than one shapes please help me to resolve the error.
    Attached Files Attached Files

  13. #13
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: change triangle size by cell inputs

    I do not understand what you want.
    How many shapes should appear?
    And where should they appear?

    Note - the rotation referencing problem does not go away just because you are starting from A1

    Please amend your worksheet to show what the sheet should look like AFTER you amend the value in cell "A1"
    thanks

  14. #14
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    Dear as you changes the value from 12 to 16 ,triangle shape changes,i think you observed that.i insert 4 triangle and called them from a1. as you know my square have corner.when i add 4 more trangle and try to call them from a1 ,other all disapear.please help me to correct the code.how i call more than one diagram in code.

    If ActiveSheet.Range("A1").Value = 16 Then
    ActiveSheet.Shapes("Right Triangle 4,"Right Triangle 9").Visible = True ,
    (i want to add more than 4 triangle in code,i used "and " "," "&" all gives error that all.hope you understand.
    please observe sheet 1. i want to apear four of same size in four corner.just remove above error and problem will be solved.bold step not working.

    i want when i right 12 in a1 all four corner triangle apears of same size as i insert 8 triangle in two corner.
    Attached Files Attached Files
    Last edited by riz4u; 04-12-2016 at 05:09 AM.

  15. #15
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: change triangle size by cell inputs

    Perhaps it is this
    I have grouped your IFs into pairs
    Also added a routine to hide all shapes


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

  16. #16
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: change triangle size by cell inputs

    ooo yes problem solved look the final results.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Re: change triangle size by cell inputs

    try this code. it allows to have more shapes for less lines of code

    Please Login or Register  to view this content.

  18. #18
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: change triangle size by cell inputs

    @riz4u looks like that is what you wanted.
    Please mark thread as solved (thread tools at top of thread)
    thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Draw triangle that changes size depending on cell values.
    By alasdairfraser in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-20-2016, 11:08 PM
  2. Change font size keeping the cell size fixed
    By mayurpatil in forum Excel General
    Replies: 1
    Last Post: 07-09-2015, 01:52 PM
  3. [SOLVED] INDEX MATCH, 3 Inputs, Slighly odd range size
    By Sordini in forum Excel General
    Replies: 7
    Last Post: 06-04-2012, 03:59 AM
  4. Change size of one cell
    By amsanborn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2008, 06:49 PM
  5. Replies: 1
    Last Post: 08-21-2006, 09:10 PM
  6. [SOLVED] How do I change the size of a check box to fit cell?
    By MTE in forum Excel General
    Replies: 0
    Last Post: 04-27-2006, 11:10 AM
  7. Microsoft Excel - Change Triangle Indicator Color
    By Thomas in forum Excel General
    Replies: 1
    Last Post: 02-08-2006, 08:20 PM

Tags for this Thread

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