muhammad susanto
Well-known Member
- Joined
- Jan 8, 2013
- Messages
- 2,077
- Office Version
- 365
- 2021
- Platform
- Windows
hi all...
this following code work properly only for single picture.
i want someone would help me to modify that code so that work in multiple picture, with logic "select your all pictures before running this macro" the run ok.
my all picture in cell N36:O36 down
here is this code :
any help, greatly appreciated..
.sst
this following code work properly only for single picture.
i want someone would help me to modify that code so that work in multiple picture, with logic "select your all pictures before running this macro" the run ok.
my all picture in cell N36:O36 down
here is this code :
VBA Code:
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
any help, greatly appreciated..
.sst
Last edited: