Hi
I am using a dynamic range to determine what picture to put into a cell, and have used a macro to try and fit the picture to the cell which is
Public Sub FitPic()
On Error GoTo NOT_SHAPE
Dim PicWtoHRatio As Single
Dim CellWtoHRatio As Single
With Selection
PicWtoHRatio = .Width / .Height
End With
With Selection.TopLeftCell
CellWtoHRatio = .Width / .RowHeight
End With
Select Case PicWtoHRatio / CellWtoHRatio
Case Is > 1
With Selection
.Width = .TopLeftCell.Width
.Height = .Width / PicWtoHRatio
End With
Case Else
With Selection
.Height = .TopLeftCell.RowHeight
.Width = .Height * PicWtoHRatio
End With
End Select
With Selection
.Top = .TopLeftCell.Top
.Left = .TopLeftCell.Left
End With
Exit Sub
NOT_SHAPE:
MsgBox "Select a picture before running this macro."
End Sub
BEFORE I GET A WARNING, THE POST WONT LET ME PUT CODE TAGS OR FORMULA TAGS AROUND THE TEXT???????
but this doesnt work? my cell has =ShowMyPic in it
Which is picking up the linked cell from a combo box
Is there a way i can get the picture to autofit the cell?
Bookmarks