robseitz74
New Member
- Joined
- Jun 9, 2020
- Messages
- 8
- Office Version
- 365
- 2013
- Platform
- Windows
I have this code that works great on a single cell but I want to apply it to a range of cells and can't seem to get it to work. Any assistance with this would be wonderful as I am creating something for work and this is the last step I need to overcome to complete the project! The code I'm starting with is:
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("J5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub
Thank you for any and all guidance as I am still new to excel and learning my way around. The issue is line 4 (With Range) if I change J5 to the range of cells I'm looking to use it on it no longer returns the pic for any cell.
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("J5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub
Thank you for any and all guidance as I am still new to excel and learning my way around. The issue is line 4 (With Range) if I change J5 to the range of cells I'm looking to use it on it no longer returns the pic for any cell.