+ Reply to Thread
Results 1 to 4 of 4

Changing Colors of Shapes

  1. #1
    Registered User
    Join Date
    05-11-2011
    Location
    istanbul
    MS-Off Ver
    Excel 2010
    Posts
    2

    Changing Colors of Shapes

    Dear all,
    I am trying to visualize profitability by city on a country map using Excel 2010.
    Is it possible to create a loop to select freeforms individually and change their background colors based on certain criteria?
    Please Login or Register  to view this content.
    I have a shape called "freeform 1056" in a sheet but when I try to access to it using a variable I get the below:

    Run Time Error 1004
    The item with the specified name wasn't found.

    Somehow it looks for freeform x rather than replacing the value of x in the argument and looking for freeform 1056.

    Can you help?

    Thanks a lot.

    Seckin
    Last edited by Leith Ross; 05-12-2011 at 03:20 PM. Reason: Added Code Tags

  2. #2
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Changing Colors of Shapes

    Usually when you want to use a variable with a name the syntax would be ("Freeform " & x)

  3. #3
    Registered User
    Join Date
    05-11-2011
    Location
    istanbul
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Changing Colors of Shapes

    Quote Originally Posted by barryleajo View Post
    Usually when you want to use a variable with a name the syntax would be ("Freeform " & x)
    I still get an error msg. Can you help me with a sample code to select several shapes using a loop?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Changing Colors of Shapes

    Hello seckin,

    You need to concatenate the number to the string. The way you have the code now, the letter "x" is added to the Shape name, not the number. Here is the corrected macro.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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