danielalvz
New Member
- Joined
- Jan 29, 2022
- Messages
- 9
- Office Version
- 2011
- Platform
- Windows
i have an existing VBA code to rezise images, but does no resize to expecific cell width and height, could any one help with the missing pieces to be changes to fix a cell, code is below, thank you in advance
Option Explicit
Public Sub FITIMAGE()
Dim X As Single
Dim Y As Single
With Selection
X = .Width / .Height
End With
With Selection.TopLeftCell
Y = .Width / .RowHeight
End With
Select Case X / Y
Case Is > 1
With Selection
.Width = .TopLeftCell.Width
.Height = .Width / X
End With
Case Else
With Selection
.Height = .TopLeftCell.RowHeight
.Width = .Height * X
End With
End Select
With Selection
.Top = .TopLeftCell.Top
.Left = .TopLeftCell.Left
End With
Exit Sub
End Sub
Option Explicit
Public Sub FITIMAGE()
Dim X As Single
Dim Y As Single
With Selection
X = .Width / .Height
End With
With Selection.TopLeftCell
Y = .Width / .RowHeight
End With
Select Case X / Y
Case Is > 1
With Selection
.Width = .TopLeftCell.Width
.Height = .Width / X
End With
Case Else
With Selection
.Height = .TopLeftCell.RowHeight
.Width = .Height * X
End With
End Select
With Selection
.Top = .TopLeftCell.Top
.Left = .TopLeftCell.Left
End With
Exit Sub
End Sub