I have a script that loops through the worksheets, looks for a Cube Value formula and then converts those to their values. That script works pretty well.
But I've found that if I create linked picture to others cells, the script is essentially bombing out/excel crashing. In searching out, I think a solution is to find your linked pictures and store those formulas into a variable and then re-insert them at the end. But I can't seem to quite figure it out.
So i'm trying to the find/loop the pictures in a worksheet, and get their formula. This is what I've got so far and it will return the original formula, but I can't seem to figure out how to re-add it.
Sub LoopThroughImages()
Dim shp As Shape
Dim F As String
Dim ws As Worksheet
Set ws = ActiveSheet
For Each shp In ws.Shapes
If shp.Type = msoPicture Then
MsgBox shp.Name & " is a picture"
'Get the linked formula
F = shp.DrawingObject.Formula
MsgBox F
'Clear it
shp.DrawingObject.Formula = ""
'Readd it
shp.DrawingObject.Formula = "=A1" 'This works
shp.DrawingObject.Formula = "=" & F 'This does not work =$AB$12:$AF$19
End If
Next shp
End Sub
Edit. I found that if the formula is A1 to begin with, then it clear and readd A1. Thus, something with adding a range of cells as the formula?
Sample file attached if it helps.
Thank you,
PT
Bookmarks