Assign object to cell/row

jealex1514

New Member
Joined
Jan 12, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have an inventory system set to add and remove data to a sheet from a user form. On that sheet I also have QR codes (as objects) generated by certain data in the inventory row. Is there any way to attach the QR code to a cell or to that row so that if I delete the item from the inventory (the row of data on the sheet) from a user form, it also removes the associated QR code? TIA
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
select the image and right click select size and properties. in the side menu, under properties, select move and size with cells.
1642023935051.png
 
Upvote 0
Solution
If you have a lot of pictures and/or want to do it through a macro you can use this:

VBA Code:
Sub attachImageToCell()
    Dim p As Picture
    For Each p In ActiveSheet.Pictures
        p.Placement = xlMove 'or xlMoveAndSize
    Next
End Sub

To delete pictures along with cells they intersect, try this:

VBA Code:
Sub deletePicture()
    Dim p As Picture
    Set Rng = ActiveSheet.Range("A1:H1") 'CHANGE THIS RANGE TO SUIT YOUR NEED
    For Each p In ActiveSheet.Pictures
        topCorner = p.TopLeftCell.Address
        If Not Intersect(Rng, ActiveSheet.Range(topCorner)) Is Nothing Then
              p.Delete
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

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