OutOfIdeas
New Member
- Joined
- Aug 23, 2011
- Messages
- 3
Hi All
I have a problem with a piece of code that appeared to be working fine for the last 3 months but now throws a "Run-time error '1004': Paste method of Worksheet class failed" error.
The idea is that a user will copy a number of columns from another workbook to the clipboard and will then click the button on my workbook, which will copy the data in and carry out a couple of other tasks too (which I've removed for simplicity). However, just recently the action has failed at the line marked below. Here's my code:
I've trawled MrExcel (a valued source of many a solution in the past) and, although I can find plenty of solutions to other people having this problem, none seem to fix mine.
During troubleshooting I have established that even if I copy a single cell from my workbook and click the button it still fails... BUT if I put simple text on the clipboard it succeeds. Can anyone help? I've been at this for 3 hours now
Thanks in advance.
I have a problem with a piece of code that appeared to be working fine for the last 3 months but now throws a "Run-time error '1004': Paste method of Worksheet class failed" error.
The idea is that a user will copy a number of columns from another workbook to the clipboard and will then click the button on my workbook, which will copy the data in and carry out a couple of other tasks too (which I've removed for simplicity). However, just recently the action has failed at the line marked below. Here's my code:
Code:
Private Sub cmdPasteAndSort_Click()
Dim intCurAcc, intCurLine As Long
Dim strCurAcc, strCurLine As String
x = MsgBox("Before you proceed please ensure that you have run the Datafile 'Sales by Product Code/Customer' report for the correct period, exported to Excel and copied columns A through L to the clipboard. Then click OK.", vbOKOnly, "Before continuing...")
'Clear columns A to L
Worksheets("Data").Columns("A:L").ClearContents
'Paste clipboard into A1
Application.CutCopyMode = False
Worksheets("Data").Range("A1").Select
ActiveSheet.Paste '<---fails here---
End Sub
I've trawled MrExcel (a valued source of many a solution in the past) and, although I can find plenty of solutions to other people having this problem, none seem to fix mine.
During troubleshooting I have established that even if I copy a single cell from my workbook and click the button it still fails... BUT if I put simple text on the clipboard it succeeds. Can anyone help? I've been at this for 3 hours now
Thanks in advance.