-
Cut & Paste Error, Excel Hang?
Hello Gurus,
I have been reading thread from this forum and everybody have a very wide knowledge of solving problems. So, I am giving a try...
Currently, I am collecting datas from a device and it is saved in the excel. In Sheet1, A1; the values changes from 1 to 0 to 1. and the values are in range of A5 to B10. When, the cell A1 changes to 1, the macro will cut and paste A5:B10 to Sheet2 and if it is zero do nothing. The macro will loop untill midnight and an email will be sent out. I will be writing this line of code later.
I ran the code and I am having this error: PasteSpecial of method range class failed. and if it works, i think the excel will hang too. Any ideas?
y = 1
Do While Sheet1.Cells(1, 1).Value = 1
Sheet1.Range("A5:B10").Cut
Sheet2.Cells(y, 1).PasteSpecial (xlPasteValues)
y = y + 9
Loop
End Sub
Thanks.
-
Excel will not let you Cut and PasteSpecial so try the following
[vba]Sheet1.Range("A5:B10").Copy
Sheet2.Cells(y, 1).PasteSpecial xlPasteValues
Sheet1.Range("A5:B10").ClearContents
[/vba] I don't see the point of the loop, as A5:B10 will be clear after the first execution
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules