+ Reply to Thread
Results 1 to 6 of 6

Dynamic Create and Position Shapes According to Cell Values for All Rows on a Worksheet

  1. #1
    Registered User
    Join Date
    04-26-2012
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    7

    Dynamic Create and Position Shapes According to Cell Values for All Rows on a Worksheet

    I know there must be a Loop to do this but I can't figure it out. Creating 4x4 chart where each column is stacked rectangles with width from a cell value and then the 2nd row is formatted differently and all are positioned next to each other (key is that size and width vary based on the cell value).

    The code works but it's messy and would have to be manually updated if additional lines are added. Anyone know a cleaner way to do this?

    Please Login or Register  to view this content.


    Column Name Value Width Height Width Height Width Height
    CNE APAC 234 49% 28% 4.007212 1.17 400.7212 117
    CNE EMEA 252 49% 31% 4.007212 1.26 400.7212 126
    CNE US 300 49% 36% 4.007212 1.5 400.7212 150
    CNE AMER 39 49% 5% 4.007212 0.195 400.7212 19.5
    CNS APAC 162 27% 35% 2.268325 1.430942 226.8325 143.0942
    CNS EMEA 175 27% 37% 2.268325 1.545771 226.8325 154.5771
    CNS US 103 27% 22% 2.268325 0.909797 226.8325 90.97966
    CNS AMER 27 27% 6% 2.268325 0.23849 226.8325 23.84904



    Moderator's Note: Welcome to the forum. You have to put code tags in you codes. Selct the codes then hit the "#" sign. I'll do it for you this time. Thank you.
    Attached Files Attached Files
    Last edited by vlady; 12-04-2012 at 08:56 PM. Reason: code tags

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

    Re: Dynamic Create and Position Shapes According to Cell Values for All Rows on a Workshee

    Hi

    Can you please edit your post and surround your code with code tags as per the forum rules.

    Then can you please advise exactly where the data you have provided is located on the sheet. I started things in A1, but this doesn't gell with the way I read your code.

    rylo

  3. #3
    Registered User
    Join Date
    04-26-2012
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Dynamic Create and Position Shapes According to Cell Values for All Rows on a Workshee

    Sorry, I thought I had put code tags around it. Thanks Moderator for helping me out. I attached the spreadsheet itself to show where the data is. The column names start in A1 but the widths and heights start in j1 and ki1 (I had to multiply them by 100 to get the right size).

    Please Login or Register  to view this content.

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

    Re: Dynamic Create and Position Shapes According to Cell Values for All Rows on a Workshee

    Hi

    First thing I'd do is add some additional columns with formulas that will work out all the relevant positions for the shapes and put them beside the existing height / width columns. Things like toppos, leftpos etc. Same thing for the RGB values. That way you can do a loop on all the items, and just pick up the relevant positioning items and color items from the row entries.

    rylo

  5. #5
    Registered User
    Join Date
    04-26-2012
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Dynamic Create and Position Shapes According to Cell Values for All Rows on a Workshee

    I've got a loop working but I can't figure out how to remove the hard-coding (i.e. instead of having if i=2 or i=4, etc have variables). I know I'll have to probably do something with Mods but not sure what. Also, I want to keep looping for all rows that have a value (whereas this is limited to row 17). Here is the updated code, any ideas?

    Please Login or Register  to view this content.

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

    Re: Dynamic Create and Position Shapes According to Cell Values for All Rows on a Workshee

    Hi

    Upload a new example file that has all the extra positioning and color options.

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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