Hi there. I have a picture that I am changing based on the result of a formula. I have a hidden sheet with all of the possible pictures sitting in cells and this part is working fine. But all of the pictures are different sizes so I am trying to run a macro to rescale the picture after the formula has changed. The pictures are quite large (basically cropped screenshots) so they are taking half a second to load and the resize macro is running before the picture has changed and therefore using the size dimensions of the old picture.
My current code is below. It's basically checking whether L13 has changed (which is part of the formula for changing the picture) and then selects the pic and resizes it.
I have tried the following and it seems to work sometimes and not others. And 3 seconds is way longer than the picture normally takes to change
I've also tried playing with Application.CalculationState and DoEvents to no avail.
Any idea how I can make sure the new picture is in there before running the resize?
Thanks
My current code is below. It's basically checking whether L13 has changed (which is part of the formula for changing the picture) and then selects the pic and resizes it.
Code:
Private Sub Worksheet_Calculate()
VConc = ActiveSheet.Range("L13").Value
If VConc <> VPreConc Then
ActiveSheet.Shapes.Range(Array("VinPic1")).Select
Selection.ShapeRange.ScaleWidth 1, msoTrue
Selection.ShapeRange.ScaleHeight 1, msoTrue
End If
VPreConc = ActiveSheet.Range("L13").Value
End Sub
I have tried the following and it seems to work sometimes and not others. And 3 seconds is way longer than the picture normally takes to change
Code:
Application.Wait (Now + TimeValue("00:00:03"))
DoEvents
I've also tried playing with Application.CalculationState and DoEvents to no avail.
Any idea how I can make sure the new picture is in there before running the resize?
Thanks