VBA Paste Special Method of Range Class Failed - Intermittent occurence
I've written code to read in a data file, create a plot, and then copy the plot and paste it as a picture onto another worksheet in the same workbook. The code does this for multiple data files.
Below is the portion of the code where the problem occurs:
Selection.Offset(27 * (ifile - 1), 0).Select
ActiveSheet.PasteSpecial format:="Picture (JPEG)", Link:=False, _
The problem is that intermittently I get an error: Paste Special Method of Range Class Failed. It fails on the last line. If I re-run the code with the same set of data files it will fail a different number of times and the files it fails on will be different. So, the actual data file does not matter. It is a problem that occurs randomly. When an error occurs I can click debug and then the run arrow to get it going again - and then the code goes on to execute everything correctly. This is the only way I can effectively process all the files I need to get through. But it means I have to babysit the code until it is finished.
I am out of things to try
Thank you for asking this question on the **Microsoft Q&A Platform. **
You have not received answers or comments to your question because it may be ambiguous or confusing.
I recommend you visit How to write a quality question and verify that your question meets some of the recommendations.
Hope this helps,
Carlos Solís Salazar
NOTE: To answer you as quickly as possible, please mention me in your reply.
Sign in to comment