Last week you have helped me by writing a code for me. The code works great. But I want to make a minor change. Some of the rows and columns in the the sheet CONSOLIDATED_RC I want to protect. (The sheet is protected). When I run the Macro gives me error:
Run-time error '1004'
Unable to set the autoFilterMode Property of the worksheet class.
The protection does not allow the macro to remove the filter. Can you please modify the code to the perform the action on the protected Consolidated_RC sheet. The code is given as under:
Sub copyRange()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Sheets("Consolidated_RC").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim foundVal As Range
Set foundVal = Sheets("Consolidated_RC").Range("D:D").Find(Sheets("Data").Range("C3").Value, LookIn:=xlValues, lookat:=xlWhole)
If Not foundVal Is Nothing Then
Sheets("Consolidated_RC").Range("D1:D" & LastRow).AutoFilter Field:=1, Criteria1:=foundVal
Sheets("Consolidated_RC").Range("B2:M" & LastRow).SpecialCells(xlCellTypeVisible).Copy
Sheets("Data").Range("B9").PasteSpecial xlPasteValues
Application.CutCopyMode = False
End If
If Sheets("Consolidated_RC").AutoFilterMode = True Then Sheets("Consolidated_RC").AutoFilterMode = False
Application.ScreenUpdating = True
End Sub
Thanks in Advance.
Khalid
Bookmarks