VBA error - Run-time error '1004' PasteSpecial method of Range class failed

tbarnes

New Member
Joined
Mar 22, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello

First time posting on such a forum so apologies for any failure in etiquette. I have tried searching for a solution to this but am struggling. I get the above error when I run the following code:

Sub Update_Comments()
'
' Update_Comments Macro
' Permanent update to comments list
'
' Keyboard Shortcut: Ctrl+l
'
Range("A1").Select
ActiveSheet.Range("$O$38:$P$238").AutoFilter Field:=1, Criteria1:="0"
ActiveSheet.Range("$O$38:$P$238").AutoFilter Field:=2, Criteria1:="1"
Range("B40:B239").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
ActiveSheet.Range("$S$38:$U$238").AutoFilter Field:=2
ActiveSheet.Range("$S$38:$U$238").AutoFilter Field:=1
ActiveSheet.Range("$S$38:$U$238").AutoFilter Field:=3, Criteria1:="1"
Range("Q39:Q" & Rows.Count).SpecialCells(xlVisible)(1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Range("$S$38:$U$238").AutoFilter Field:=3
Range("A1").Select
End Sub

This code has been cobbled together from recording a macro and searching the web to try and achieve what I want to achieve which is:

Copy data from a range of visible cells once some filters have been applied, clear those filters and then apply a new filter for a new range, identify the first visible cell in the new range and paste the copied data in that column starting from the first visible cell in the filtered range (all other cells beneath the first visible cell are all visible).

Many thanks for any help
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Watch MrExcel Video

Forum statistics

Threads
1,130,335
Messages
5,641,555
Members
417,220
Latest member
lam150498

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top