Excel Guides

Copying Pictures with a Macro in Excel

There are a few different ways to copy pictures with a macro in Excel. The first way is to use the CopyPicture method.

The CopyPicture method has a few different arguments that you can use to control how the picture is copied. The first argument is the Appearance. This argument controls whether the picture is copied with or without borders and other formatting.

The second argument is the Format. This argument controls what format the picture will be copied in. The most common formats are Bitmap, JPEG, and PNG. You can also use the Format argument to control how much detail is included in the copy.

The CopyPicture Method

  1. Open your workbook in Excel.
  2. Click on the worksheet that contains the picture you want to copy.
  3. Click on the picture.
  4. Press Alt+F11 to open the Visual Basic Editor (VBE).
  5. In the VBE, double click on your workbook name in the Project Explorer window.
  6. Insert a new module by clicking on Insert > Module.
  7. In the new module, type or paste this code:
Sub CopyPicture()
  Dim ws As Worksheet
  Dim pic As Picture

  Set ws = ActiveSheet

  For Each pic In ws.Pictures

    pic.CopyPicture Appearance:=xlScreen, Format:=xlBitmap

    With ws.Range("A1")

      .PasteSpecial

      .RowHeight = pic.Height

      .ColumnWidth = pic.Width

    End With

  Next
End Sub

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.