Results 1 to 3 of 3

Selecting Shapes With Variable Based On Worksheet Data

Threaded View

  1. #1
    Registered User
    Join Date
    12-14-2011
    Location
    Edmonds, Washington
    MS-Off Ver
    Excel 2010
    Posts
    2

    Selecting Shapes With Variable Based On Worksheet Data

    I'm working on a macro that automatically highlights a map based on the data within my worksheet. There are 35 areas on my map each with their own shape that is named for the number of the map area (100, 110, 120 to 750, 760, 770).

    I need to be able to select the shape corresponding to the area so I can properly format it...

    Here's my code thus far:
    
    BuyersMarket = ActiveSheet.Range("U2")
    SellersMarket = ActiveSheet.Range("U3")
    
    For Row = 3 To 37
    
        Area = Cells(Row, 2).Value
        Inventory = Cells(Row, 3).Value
        
       
    If Inventory > BuyersMarket Then
    
        ActiveSheet.Shapes.Range(Array(Area)).Select
        With Selection.ShapeRange.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(0, 128, 0)
            .Transparency = 0.5
            .Solid
        End With
        With Selection.ShapeRange.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(0, 128, 0)
            .Transparency = 0
        End With
    
    ElseIf Inventory < SellersMarket Then
    
        ActiveSheet.Shapes.Range(Array("Area760")).Select
        With Selection.ShapeRange.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(192, 0, 0)
            .Transparency = 0.5
            .Solid
        End With
        With Selection.ShapeRange.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(192, 0, 0)
            .Transparency = 0
        End With
    
    Else
    
        ActiveSheet.Shapes.Range(Array("Area760")).Select
        With Selection.ShapeRange.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 255, 0)
            .Transparency = 0.5
            .Solid
        End With
        With Selection.ShapeRange.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 255, 0)
            .Transparency = 0
        End With
    
    End If
    
    Next
    However, this part doesn't work:
    "ActiveSheet.Shapes.Range(Array(Area)).Select"


    So I need to know how to properly specify a variable that I can use to select the shape so that I can assign it the right color.

    Any ideas?
    Last edited by svAndiamo; 12-15-2011 at 02:21 PM.

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