vbalearner11
New Member
- Joined
- Jan 19, 2018
- Messages
- 18
I have a very large program and i am getting error when running. Can somebody please help me how to fix this problem. Getting error when it is pasting to "D1" Error message says: Run-time error '1004' You can't paste this here because the Copy area and paste area aren't the same size select just one cell in the paste area or an area that's the same size, and try pasting it again.
Here's the code as follows
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">If lastROWduplicate >1Then
Range(Cells(2,1), Cells(lastROWduplicate,1)).SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Range("D1").PasteSpecial xlPasteValues '--->>> This line throws error
OnErrorResumeNext
DuplicateWKSHT.ShowAllData
OnErrorGoTo0
lastROWduplicate = DuplicateWKSHT.Cells(DuplicateWKSHT.Rows.Count,"D").End(xlUp).Row
DuplicateINX =1
DuplicateProjects =""
For DuplicateINX =1To lastROWduplicate
DuplicateProjects = DuplicateProjects & Chr(10)&CStr(Range("D"& DuplicateINX).Value)
If DuplicateINX = lastROWduplicate Then
MsgBox ("Error! The following project(s) appear at more than once in the Conso for the "& Curr.Name &"tab:"& Chr(10))
EndIf
Next
EndIf</code>
Here's the code as follows
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">If lastROWduplicate >1Then
Range(Cells(2,1), Cells(lastROWduplicate,1)).SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Range("D1").PasteSpecial xlPasteValues '--->>> This line throws error
OnErrorResumeNext
DuplicateWKSHT.ShowAllData
OnErrorGoTo0
lastROWduplicate = DuplicateWKSHT.Cells(DuplicateWKSHT.Rows.Count,"D").End(xlUp).Row
DuplicateINX =1
DuplicateProjects =""
For DuplicateINX =1To lastROWduplicate
DuplicateProjects = DuplicateProjects & Chr(10)&CStr(Range("D"& DuplicateINX).Value)
If DuplicateINX = lastROWduplicate Then
MsgBox ("Error! The following project(s) appear at more than once in the Conso for the "& Curr.Name &"tab:"& Chr(10))
EndIf
Next
EndIf</code>
Last edited: