Paste Special Method of Range Class Failed

aejaz7

New Member
Joined
Nov 6, 2018
Messages
2
i want to paste special for following macro on destination range.Paste special not working.
how to execute paste special in following condition.

please reply if any one have such solution.


Code:
Private Sub CommandButton1_Click()    Dim wkbCrntWorkBook As Workbook
    Dim wkbSourceBook As Workbook
    Dim rngSourceRange As Range
    Dim rngDestination As Range
    Set wkbCrntWorkBook = ActiveWorkbook
    With Application.FileDialog(msoFileDialogOpen)
        .Filters.Clear
        .Filters.Add "Excel 2007-13", "*.xls; *.xlsx; *.xlsm; *.xlsa"
        .AllowMultiSelect = False
        .Show
        If .SelectedItems.Count > 0 Then
            Workbooks.Open .SelectedItems(1)
            Set wkbSourceBook = ActiveWorkbook
            Set rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A1", Type:=8)
            wkbCrntWorkBook.Activate
            Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A5", Type:=8)
            rngSourceRange.Copy rngDestination
            ActiveSheet.Unprotect Password:="123"
            rngDestination.CurrentRegion.EntireColumn.AutoFit
            wkbSourceBook.Close False
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123"
        End If
    End With


End Sub
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,980
Office Version
365
Platform
Windows
Your VBA is trying to paste on protected sheet
- unprotect sheet BEFORE copy & paste
 

Forum statistics

Threads
1,086,116
Messages
5,387,925
Members
402,089
Latest member
Exceliamus

Some videos you may like

This Week's Hot Topics

Top