Title: Paste Special error 1004 PasteSpecial method of Range class failed VBA. Can i handle it using error handling?
Tags: excel;vba
Question: I have looked over the solutions for this Run time error over whole internet, but was not able to find something useful for my code.
can i use Try &amp; Catch here for re-running that specific part of code, Because every time i run my  code stops on the below mentioned line and i press F8 code starts running back.
Paste special error occurs whenever i try to run code for bulk files.
Please refer error lines below with **
Look on the code below:
If lRnewapp &gt;1 Then
wksoldApp. Unprotect &quot;iti3.0&quot; wksoldApp.Range(&quot;A2:D&quot;&amp;Roldapp).ClearContents
Application. Wait (Now () + TimeValue(&quot;00:00:02&quot;))

WksNewApp.Range(&quot;B2:C&quot; &amp; 1Rnewapp).Copy
Application. Wait (Now () + TimeValue(&quot;00:00:01&quot;))

**wksoldApp.Range(&quot;A2&quot;). Paste Special (xl PasteValue)**
Application. Wait (Now) + TimeValue(&quot;00:00:02&quot;))

**wksNewApp.Range(&quot;D2:D&quot; &amp; 1Rnewapp).Copy**
Application. Wait (Now I) + TimeValue(&quot;00:00:02&quot;))

**WksoldApp.Range(&quot;D2&quot;). Paste Special (x1 Pastevalue)**
Application. Wait (Now () + TimeValue(&quot;00:00:02&quot;}

wksNewApp.Range(&quot;E2:E&quot; &amp; 1Rnewapp). Copy
Application. Wait (Now) + TimeValue(&quot;00:00:01&quot;))

wksOldApp.Range(&quot;C2&quot;). Paste Special (xl PasteValues)
Application. Wait (Now) + TimeValue(&quot;00:00:02&quot;))

wksoldApp.Range(&quot;A2:D2&quot;).Copy
Application. Wait (Now) + TimeValue(&quot;00:00:01&quot;))

wksoldApp.Range(&quot;A3:D&quot; 1Rnewapp). Paste Special xl Paste formats
Application. Wait (Now) + TimeValue(&quot;00:00:01&quot;))

wksoldApp. Protect it13.0&quot;, AllowFormattingcolumna:-True, AllowFormattingRows: True, userinterfaceonly: True, AllowFiltering: True

wkoldApp.Range(&quot;E2&quot;) - int (A2)
wksoldApp.Range(&quot;E2:E&quot; &amp; 1 Rnewapp) .Fill Down
Application. Wait (Now) + TimeValue(&quot;00:00:02&quot;))

wksOldApp.Range(&quot;E2:E&quot; &amp; 1Rnewapp).Copy
Application. Wait (Now () + TimeValue(&quot;00:00:01&quot;))

wksoldApp.Range(&quot;A2&quot;). Paste Special (xlPasteValues)
wksoldApp.Columns (2). Number Format - &quot;O&quot;
wksoldApp.Range(&quot;E:E&quot;).clearContents
wksoldApp.Range(&quot;A2&quot;). BorderAround xlThin
wksoldApp.Range(&quot;A2&quot;).Copy
wksoldApp.Range(&quot;A2:D&quot; &amp; 1newapp). PasteSpecial xl Paste Format
WksoldApp.Range(&quot;AZ:D&quot; IRnewapp). Font.Size - &quot;S&quot;

End If
Comment: Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

Comment: Yes you can use regular VBA error handling: see here for a good overview  - http://www.cpearson.com/excel/errorhandling.htm#:~:text=On%20Error%20Goto%20%3A,to%20terminate%20the%20VBA%20program.   Please do not post code as a picture - you can copy/paste the relevant section to your post as text.

Comment: @TimWilliams Thanks for sharing the material, It'll definitely help me out.

Comment: @TimWilliams can you please take a look. ?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:02/28/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<excel><vba>', 'Title': 'Paste Special error 1004 PasteSpecial method of Range class failed VBA. Can i handle it using error handling?', 'ViewCount': 41, 'id': 71292822, 'user_AboutMe': '', 'user_AccountId': 19399597.0, 'user_DisplayName': 'PeakyCoder', 'user_Reputation': 1.0, 'user_Views': 1.0, 'user_id': 14186467.0}}