Using a picture using a fixed sheet link

Throwaway8843

New Member
Joined
Jun 29, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I am trying to write a macro in VBA whereby I can utilized the linked picture functionality but have the formula of the picture be something like =Sheet1!$G$17:$I$22 instead of the standard =$G$17:$I$22 that way I can copy the linked picture across sheets.

The following formula gives me the required picture, but is not absolute referencing the sheet, just the cells. So if I copy and paste the picture to a new sheet it will look at say cells $G$17:$I$22 in the new sheet instead of sheet1.

VBA Code:
Sub LinkedPicture()

Dim cell As Range
Dim rng As Range
Set rng = Selection

For Each cell In rng
If cell.Interior.ColorIndex = xlNone Then
cell.Interior.ColorIndex = xlAutomatic
With cell.Borders
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
End If

Next cell

Selection.Copy
ActiveSheet.Pictures.Paste(Link:=True).Select

End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Maybe as a workaround you could first paste it into a separate worksheet instead. This will provide you with an absolute reference, which includes a reference to the worksheet. Then you can continue with what you need to do.
 
Upvote 0
Maybe as a workaround you could first paste it into a separate worksheet instead. This will provide you with an absolute reference, which includes a reference to the worksheet. Then you can continue with what you need to do.
An interesting thought. I could try to create a new sheet, paste in, then cut the picture, paste back to the original place, and remove the new sheet. Could work but seems like it might significantly slow down the time taken to run the macro.
 
Upvote 0
While it is somewhat inefficient, it probably won't be as bad as you might expect. Especially if you set ScreenUpdating to False at the beginning of your code, and then set it back to True at the end.

Also, if it's something that you're going to do repeatedly, you could always create a permanent worksheet for this purpose. This way you won't have to keep creating one, and then deleting it. You could hide the worksheet so that that it's not visible.

And, if you set the Visible property to xlSheetVeryHidden, the user won't be able to see it at all, nor will he/she be able to make it visible.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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