+ Reply to Thread
Results 1 to 5 of 5

Cell contents to affect Autoshapes color

  1. #1
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63

    Cell contents to affect Autoshapes color

    I have several lines (autoshape line) of the color blue
    and would like to change the color of the line to white (or Hide)
    if Cell A1="F"

    Problem is that Drawn lines do not exist in cells they only have a name
    Any Ideas????

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

    Here are two macros to hide and unhide all the lines on the activeworksheet.
    _________________________________________________________________

    Public Sub HideLines()

    Dim I As Integer

    With ActiveSheet
    For I = 1 To .Shapes.Count
    If .Shapes(I).Type = msoLine Then .Visible = False
    Next I
    End With

    End Sub

    _________________________________________________________________

    Public Sub ShowLines()

    Dim I As Integer

    With ActiveSheet
    For I = 1 To .Shapes.Count
    If .Shapes(I).Type = msoLine Then .Visible = True
    Next I
    End With

    End Sub

    _________________________________________________________________

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    I just want to hide specific named lines not all lines

    for instance
    I have 4 blue lines, 3 red lines and 2 green lines
    if Cell Sheet!A1 = F then hide blue lines, if Cell Sheet1!A1=A then hide green lines but show
    blue and red lines.

    and the sheet is not active, Cell A1 is Sheet1!A1
    Lines are on Sheet2
    Last edited by swieduwi; 04-25-2005 at 06:50 AM.

  4. #4
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63

    Help

    So far I have come up with this and it does work.
    Is there a better way to do this??????
    It just looks poor?


    Private Sub Worksheet_Calculate()

    Dim shp1 As Shape
    Dim shp2 As Shape
    Dim shp3 As Shape
    Dim shp4 As Shape

    Select Case Range("A23").Value

    Case Is = "f"
    Set shp1 = Sheets("Diagram (HA)").Shapes("BlueLine_1")
    shp1.Line.Visible = msoFalse

    Set shp2 = Sheets("Diagram (HA)").Shapes("BlueLine_2")
    shp2.Line.Visible = msoFalse

    Set shp3 = Sheets("Diagram (HA)").Shapes("BlueLine_3")
    shp3.Line.Visible = msoFalse

    Set shp4 = Sheets("Diagram (HA)").Shapes("BlueLine_4")
    shp4.Line.Visible = msoFalse

    Case Else
    Set shp1 = Sheets("Diagram (HA)").Shapes("BlueLine_1")
    shp1.Line.Visible = msoTrue

    Set shp2 = Sheets("Diagram (HA)").Shapes("BlueLine_2")
    shp2.Line.Visible = msoTrue

    Set shp3 = Sheets("Diagram (HA)").Shapes("BlueLine_3")
    shp3.Line.Visible = msoTrue

    Set shp4 = Sheets("Diagram (HA)").Shapes("BlueLine_4")
    shp4.Line.Visible = msoTrue

    End Select

    End Sub
    Last edited by swieduwi; 04-25-2005 at 12:41 PM.

  5. #5
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63

    Help With VB Code

    I have also tried Leith Ross suggestion, but adding my requirments with no success.

    Private Sub Worksheet_Calculate()

    Dim I As Integer

    Select Case Range("A23").Value

    Case Is = "f"
    With Worksheets("Diagram (HA)")
    For I = 1 To .Shapes("BlueLine_").Count
    If .Shapes(I).Type = msoLine Then .Visible = False
    Next I
    End With

    Case Else
    With Worksheets("Diagram (HA)")
    For I = 1 To .Shapes("BlueLine_").Count
    If .Shapes(I).Type = msoLine Then .Visible = True
    Next I
    End With

    End Select

    End Sub
    Last edited by swieduwi; 04-25-2005 at 11:12 AM.

+ 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