Clipboard error while paste data

negi

Board Regular
Joined
Apr 16, 2009
Messages
87
Hi All,
I m using below code for merge sheet but its asking for clipboard while paste every file (there is a large amount of information on the clipboard,Do you want to be able to paste this information in to onother program later?.
I have 20K to 40K rows in every sheets.Please help

Sub CopyRange() Application.ScreenUpdating = False
Dim wkbDest As Workbook
Dim wkbSource As Workbook
Set wkbDest = ThisWorkbook
Dim LastRow As Long
Dim irow As Long
Const strPath As String = "D:\New\2015\IMFL\Apr"
ChDir strPath
strExtension = Dir("*.xlsx*")
Do While strExtension <> ""
Set wkbSource = Workbooks.Open(strPath & strExtension)
With wkbSource
irow = Cells(Rows.Count, 34).End(xlUp).Row
'************************************************************************
Range("AL13").Select
With Selection
.MergeCells = True
End With
Selection.UnMerge
Range("U11").Copy Range("AL13:AL" & irow)

Range("AM13").Select

ActiveCell.Formula = "=CONCATENATE(G10,U10)"

Range("AM13").Copy
Range("AM13:AM" & irow).PasteSpecial Paste:=xlPasteValues


'ActiveCell.FormulaR1C1 = "=RC[-3]&RC[-2]"
'Range("F8").Select

' LastRow = .Sheets("Report").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Sheets("Report").Range("A13:AM" & irow).Copy wkbDest.Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
.Close savechanges:=False
End With
strExtension = Dir
Loop
Application.ScreenUpdating = True
End Sub
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Maybe (change Sheets(1) to suit... probably "Report")...

Rich (BB code):
Sub CopyRange()

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
    End With

    Dim wkbDest As Workbook
    Dim wkbSource As Workbook
    Set wkbDest = ThisWorkbook
    Dim LastRow As Long
    Dim irow As Long

    Const strPath As String = "D:\New\2015\IMFL\Apr"
    ChDir strPath
    strExtension = Dir("*.xlsx*")

    Do While strExtension <> ""
        Set wkbSource = Workbooks.Open(strPath & strExtension)
        With wkbSource
            With .Sheets(1)
                irow = .Cells(Rows.Count, 34).End(xlUp).Row
                .Range("U11").Copy .Range("AL13:AL" & irow)

                With .Range("AM13:AM" & irow)
                    .Formula = "=CONCATENATE(G10,U10)"
                    .PasteSpecial Paste:=xlPasteValues
                End With

            End With
            Sheets("Report").Range("A13:AM" & irow).Copy wkbDest.Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)

            .Close savechanges:=False
        End With
        strExtension = Dir
    Loop

    With Application
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With

End Sub
 
Last edited:
Upvote 0
How can you merge a single cell? that you also unmerge directly after merging before the copy. From your code...

Code:
Range("AL13").Select
 With Selection
 .MergeCells = True
 End With
 Selection.UnMerge

and the data from U11 is being copy/pasted in the line below . Did you try the code?

Code:
.Range("U11").Copy .Range("AL13:AL" & irow)
 
Last edited:
Upvote 0
Try clearing the clipboard before closing the files with this.
Code:
Application.CutCopyMode  = False
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top