lengyel109
New Member
- Joined
- Jan 10, 2022
- Messages
- 4
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
Hello there!
I ran into some issues using VBA with my limited knowledge.
I am trying to combine a code to delete pictures in a range, which works as it should:
With an If statement to set the range, if a specific sheet is active:
The yellow part is where I get a run time error '1004' Method 'Range of object'_Global' failed.
So I guess I messed the string somehow right?
This would ofc repeat with different sheet names, with each sheet having a different end range.
Any ideas?
Thanks in Advance, Mark
I ran into some issues using VBA with my limited knowledge.
I am trying to combine a code to delete pictures in a range, which works as it should:
VBA Code:
Dim pic As Object
For Each pic In ActiveSheet.Pictures
If Not Application.Intersect(pic.TopLeftCell, Range("A8:T35")) Is Nothing Then
pic.Delete
End If
Next pic
End Sub
Rich (BB code):
Dim pic As Object
Dim lc As String
If ActiveSheet.Name = "ESC 1-4" Then lc = (G35)
For Each pic In ActiveSheet.Pictures
If Not Application.Intersect(pic.TopLeftCell, Range("A8:lc")) Is Nothing Then
pic.Delete
End If
Next pic
End Sub
So I guess I messed the string somehow right?
This would ofc repeat with different sheet names, with each sheet having a different end range.
Any ideas?
Thanks in Advance, Mark
Last edited by a moderator: