Results 1 to 2 of 2

VBA Dynamic Pictures Not Deleting (sometimes)

Threaded View

gtnilc VBA Dynamic Pictures Not... 05-11-2021, 05:52 PM
gtnilc Re: VBA Dynamic Pictures Not... 05-13-2021, 02:34 AM
  1. #1
    Registered User
    Join Date
    05-10-2021
    Location
    Long Beach
    MS-Off Ver
    365
    Posts
    8

    VBA Dynamic Pictures Not Deleting (sometimes)

    I have a file where there are multiple rows.

    Column A has a value and in another column, the corresponding image will appear. If the value is deleted, the corresponding image will disappear. If the value changes, the image will change based on the corresponding value.

    My problem is that sometimes it deletes, and sometimes it doesn't. When I tried this on different computers, it worked perfectly but when on another computer, none of the images self delete when the value is deleted.

    Can someone help me refine the VBA code I am using?

    Thanks

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim pic As Picture
    If Intersect(Target, [A:A]) Is Nothing Then Exit Sub
    On Error GoTo son
    
    For Each pic In ActiveSheet.Pictures
        If Not Application.Intersect(pic.TopLeftCell, Range(Target.Offset(0, 3).Address)) Is Nothing Then
        pic.Delete
        End If
    Next pic
    
    Dim fPath As String
        fPath = "G:\My Drive\Images"
        'If Target.Value <> "" And Dir(fPath & Target.Value & ".jpg").select
    ActiveSheet.Pictures.Insert(fPath & "\" & Target.Value & ".jpg").Select
    Selection.Top = Target.Offset(0, 2).Top
    Selection.Left = Target.Offset(0, 4).Left
    Selection.ShapeRange.LockAspectRatio = msoFalse
    Selection.ShapeRange.Height = Target.Offset(0, 2).Height
    Selection.ShapeRange.Width = Target.Offset(0, 4).Width
    Target.Offset(0, 1).Select
    son:
    
    End Sub
    Last edited by gtnilc; 05-13-2021 at 02:37 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel's Compress Pictures or deleting pictures doesn't seem work
    By guidod in forum Excel General
    Replies: 1
    Last Post: 01-29-2006, 02:50 AM
  2. deleting 100's of pictures, keep data
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  3. deleting 100's of pictures, keep data
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 AM
  4. deleting 100's of pictures, keep data
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. deleting 100's of pictures, keep data
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  6. deleting 100's of pictures, keep data
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. [SOLVED] Deleting Pictures
    By Shatin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2005, 02:05 PM
  8. [SOLVED] Deleting Pictures
    By brmauer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2005, 07: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