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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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