Throwaway8843
New Member
- Joined
- Jun 29, 2021
- Messages
- 13
- Office Version
- 365
- Platform
- 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.
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