Results 1 to 3 of 3

Delete single picture from sheet and leave others

Threaded View

  1. #1
    Registered User
    Join Date
    07-02-2018
    Location
    australia
    MS-Off Ver
    2016
    Posts
    60

    Delete single picture from sheet and leave others

    Hi all
    I have several pictures on my sheet one being the header the other inserts into J6
    When D2 has specific text a corresponding picture appears in J6, As D2 changes the picture is deleted and a new picture inserted into J6
    The code below deletes all pictures from the sheet than updates J6 including the header
    I want the header picture to stay always
    i have tried many different things but still deletes all
    Any help is greatly appreciated

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Dim myPict As Picture
    Dim PictureLoc As String
    
    If Target.Address = Range("D2").Address Then
    
    ActiveSheet.Pictures.Delete.myPict
    PictureLoc = "C:\Users\dmott\Desktop\TEMP PICS EXCEL\" & Range("D2").Value & ".png"
    
    With Range("J6")
        Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
        myPict.Top = .Top
        myPict.Left = .Left
        myPict.ShapeRange.LockAspectRatio = msoFalse
        myPict.Placement = xlMoveAndSize
        myPict.ShapeRange.Width = 250
        myPict.ShapeRange.Height = 168
        
    End With
    
    End If
    
    End Sub
    Last edited by danny25; 12-28-2019 at 06:27 AM. Reason: solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to randomly delete X amount of rows from a sheet in a single command?
    By orange109 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2018, 04:33 AM
  2. [SOLVED] VBA delete the Table Body in 4 tables new sheet, leave headers & subtotals.
    By kjg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2017, 07:56 AM
  3. [SOLVED] Mulitple rows to a single column leave blanks out
    By RJK in forum Excel General
    Replies: 4
    Last Post: 12-03-2016, 12:23 AM
  4. [SOLVED] Sum columns (duplicates in row header) & delete duplicate cols to leave single unique cols
    By kinrossfarm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 05:50 AM
  5. Replies: 3
    Last Post: 04-17-2011, 03:23 AM
  6. Delete Duplicates Leave one
    By bangelta in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2010, 06:47 PM
  7. LEN fuction to leave a single character
    By Jonah in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-22-2006, 11:35 AM

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