+ Reply to Thread
Results 1 to 1 of 1

Adding in dynamically scaling shapes to existing code

Hybrid View

  1. #1
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Adding in dynamically scaling shapes to existing code

    Hello all,

    I am trying to expand upon my current code (developed with much help from the forum already) to increase the tracking capability of the workbook it is applied to.

    In the attached example workbook, you will see a "Before" and "After" look that I am trying to achieve.

    The "Before" look generates shapes to overlay key words that match the shape's name - this is used as somewhat of a scheduling tool and works well for my purposes.

    What I am now trying to achieve is a scaling rectangular shape that will fill the void in between my Start and Finish dates, that will be dynamic. I'm not sure of where to start or the best way to approach this, so help is appreciated.

    Working preliminary code (also in sample workbook):

    Option Explicit
    
    'Private Sub Worksheet_Calculate()
    
    Dim myCell As Range 'Calls the Named Ranges needed for the code to run
    Dim mySel As Range
    Dim myR As Range 'Sets dimension to center pictures within cell
    Dim myS As Shape
    
    
    Set mySel = Selection
    
    With Application
       .ScreenUpdating = False
    
    On Error Resume Next 'Checks first to see if a cell within the named range is blank, skips if it is, and calls the appropriate image if not
       For Each myCell In Range("KeyCells")
             If myCell <> "" Then
                     ActiveSheet.Shapes(myCell.Address & "Final").Delete 'Deletes old image and replaces it with the called new one
                     ActiveSheet.Shapes(myCell.Value).Select
                     Selection.Copy
                     myCell.Offset(0, 0).Select
                     ActiveSheet.Paste
                     Selection.Name = myCell.Address & "Final"
                     Selection.ShapeRange.ZOrder msoSendToBack
                     With Selection 'Centers pictures within cell
                     Set myR = .TopLeftCell
                     .Left = myR.Left + (myR.Width - .Width) / 2
                     .Top = myR.Top + (myR.Height - .Height) / 2
                     End With
              Else: ActiveSheet.Shapes(myCell.Address & "Final").Delete
              GoTo Skip
        End If
    Skip:
    Next myCell
    mySel.Select
    
       .ScreenUpdating = True
    
    End With
    
    End Sub
    Attached Files Attached Files
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

+ 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. [SOLVED] adding a value to existing code
    By bnwash in forum Excel General
    Replies: 16
    Last Post: 06-05-2015, 07:40 PM
  2. Adding to some existing VBA code
    By richard11153 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 03-10-2014, 08:31 PM
  3. An example using and scaling shapes (circle).
    By xladept in forum Excel Tips
    Replies: 0
    Last Post: 04-26-2013, 07:39 PM
  4. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  5. Help adding to existing code
    By Jrykiss in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-02-2010, 06:11 PM
  6. Scaling shapes
    By SJB in forum Excel General
    Replies: 1
    Last Post: 12-29-2009, 11:55 AM
  7. Scaling a chart that has been dynamically created in vb
    By Mark in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 05-27-2005, 04:05 PM

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