Copy Range and Paste as Picture Excel VBA (Visual Basic for Applicaiton)

Copy Range and Paste as Picture Excel VBA (Visual Basic for Applicaiton)

CopyPicutre

CurrentRegion object exposes method which allows user to create a range for selected range and can be pasted or printed directly using VBA. In this post I will teach how you can copy a range and paste as picture using VBA.

Source data

Code

Public Sub PasteRangeAsPicture()
    'Declare Range object
    Dim oRange As Range
    
    'Bind selection to range
    Set oRange = Selection
    
    'Copy range as picture
    oRange.CurrentRegion.CopyPicture xlScreen, xlBitmap
    
    'Paste range where you want
    
    ActiveSheet.paste
    
    'Cleanup
    If Not oRange Is Nothing Then
        Set oRange = Nothing
    End If
End Sub

Output

Next >> Create or customize ribbon in Excel with example

Leave a Reply

Your email address will not be published.