Forum Discussion

Costafeller's avatar
Costafeller
Copper Contributor
Jul 18, 2021
Solved

[VBA] Copy image to workbook

Hey everyone,   I have an excel file with several formulas taking data from another "raw" excel file. This excel file is basically doing all the necessary calculations and automatically putting al...
  • HansVogelaar's avatar
    Jul 18, 2021

    Costafeller 

    For example:

    Sub CopyToNew()
        Dim w1 As Worksheet
        Dim wb As Workbook
        Dim w2 As Worksheet
        Set w1 = ActiveSheet
        w1.UsedRange.SpecialCells(xlCellTypeVisible).Copy
        Set wb = Workbooks.Add
        Set w2 = wb.Worksheets(1)
        w2.Range("A1").PasteSpecial xlPasteColumnWidths
        w2.Range("A1").PasteSpecial xlPasteValues
        w2.Range("A1").PasteSpecial xlPasteFormats
        w1.Shapes("Picture 4").Copy
        w2.Paste
    End Sub

Resources