How move a picture by code (VBA)?

  • Thread starter Thread starter Min
  • Start date Start date
M

Min

Hi, I want to move a picture to a position, say, ColumnB and Row2 (or Cell
B2) with its up-left coner the same as the cell. And I need resize the
picture to fit in cell(B2:C3). What the VBA code to do this? I tried using
record Macro, but the code is not easy to use.
 
The following code will move picture 1 to fit over cells B2:C3 --

'=======================
Sub MovePicture()
Dim ws As Worksheet
Dim rng As Range
Set ws = Sheets("Sheet1")
Set rng = ws.Range("B2:C3")

With ws.Shapes("Picture 1")
.LockAspectRatio = msoFalse
.Top = rng.Top
.Left = rng.Left
.Height = rng.Height
.Width = rng.Width
End With
End Sub
'==========================
 
Back
Top