Rename pictures in a particular cell

yinkajewole

Active Member
Joined
Nov 23, 2018
Messages
281
I have pictures on range F7 in all sheets. unfortunately the names of the picture varies in all the sheets. how do i give it a uniform name like "mypic"
 
@eduzs It errors Method or data member not found
Rich (BB code):
If Not Intersect(Range(oSheet.oShp.TopLeftCell.Address), oSheet.range("F7")) Is Nothing Then oSheet.oShp.name="UnicName"
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I got this $F$7

Well in that case my code should work ...

If you amend the PicFromRange function as follows and re-run the Test sub again, do you get the sheest, shapes and respective topleft cells in the immediate window?
Code:
Function PicFromRange(ByVal R As Range) As Shape

    Dim shp As Shape
    
    For Each shp In R.Worksheet.Shapes
        If shp.TopLeftCell.Address = R.Address Then
           [COLOR=#0000ff][B] Debug.Print shp.ControlFormat.Parent.Name & vbTab & shp.Name & vbTab & shp.TopLeftCell.Address[/B][/COLOR]
            Set PicFromRange = shp: Exit Function
        End If
    Next shp


End Function
 
Upvote 0
You could not move all at once just by the same name.
 
Upvote 0
Well in that case my code should work ...

If you amend the PicFromRange function as follows and re-run the Test sub again, do you get the sheest, shapes and respective topleft cells in the immediate window?
Code:
Function PicFromRange(ByVal R As Range) As Shape

    Dim shp As Shape
    
    For Each shp In R.Worksheet.Shapes
        If shp.TopLeftCell.Address = R.Address Then
           [COLOR=#0000ff][B] Debug.Print shp.ControlFormat.Parent.Name & vbTab & shp.Name & vbTab & shp.TopLeftCell.Address[/B][/COLOR]
            Set PicFromRange = shp: Exit Function
        End If
    Next shp


End Function

I got nothing....
When I pressed F8 to run the code line by line, when it got to the function, it did nothing, it then went to end function - that's what I notice
 
Upvote 0
I got nothing....
When I pressed F8 to run the code line by line, when it got to the function, it did nothing, it then went to end function - that's what I notice

That suggests the line :If shp.TopLeftCell.Address = R.Address Then evaluates to FALSE meaning no shape is located in cell F7.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,447
Messages
6,124,906
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top