Есть макрос, который позволяет вставить картинку и подогнать ее под размеры ячейки автоматически. Что нужно добавить в код, чтобы картинка помещалась в ячейку с отступом в 2 пикселя от краев?
[vba]
Код
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Range("B:B"), Target) Is Nothing Then If Application.Dialogs(xlDialogInsertPicture).Show Then With Selection .ShapeRange.LockAspectRatio = msoTrue .Height = Target.Height If .Width > Target.Width Then .Width = Target.Width End If End With End If End If End Sub
[/vba]
Спасибо заранее за ответ.
Добрый день!
Есть макрос, который позволяет вставить картинку и подогнать ее под размеры ячейки автоматически. Что нужно добавить в код, чтобы картинка помещалась в ячейку с отступом в 2 пикселя от краев?
[vba]
Код
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Range("B:B"), Target) Is Nothing Then If Application.Dialogs(xlDialogInsertPicture).Show Then With Selection .ShapeRange.LockAspectRatio = msoTrue .Height = Target.Height If .Width > Target.Width Then .Width = Target.Width End If End With End If End If End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Range("B:B"), Target) Is Nothing Then Exit Sub If Application.Dialogs(xlDialogInsertPicture).Show Then With Selection .Height = Target.Height - 2 .Top = Target.Top + 1 .Left = Target.Left + 1 If .Width > Target.Width Then .Width = Target.Width - 1 End With End If End Sub
[/vba]
Привет, Henry, так?: [vba]
Код
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Range("B:B"), Target) Is Nothing Then Exit Sub If Application.Dialogs(xlDialogInsertPicture).Show Then With Selection .Height = Target.Height - 2 .Top = Target.Top + 1 .Left = Target.Left + 1 If .Width > Target.Width Then .Width = Target.Width - 1 End With End If End Sub