Runtime error '438': Object doesn't support this property or method

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Running office 365

VBA Code:
Sub Filter()
        
        ActiveSheet.Activate
        ActiveSheet.Unprotect
        
        If ActiveSheet.Name <> Worksheets("WO Report Summary 4.0") Then
            Rows("1:1").Select
            Selection.AutoFilter
            cells.Select
            cells.EntireColumn.AutoFit
        Else
            Rows("1:1").Select
            Selection.AutoFilter
            cells.Select
            cells.EntireColumn.AutoFit
            Range("L5:M5").ColumnWidth = 10.14
        End If
        
        Worksheets("WO Report Summary 4.0").Protect

End Sub

Error occurs on this line:
VBA Code:
If ActiveSheet.Name <> Worksheets("WO Report Summary 4.0") Then

Thank you
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try just
VBA Code:
If ActiveSheet.Name <> "WO Report Summary 4.0" Then
 
Upvote 0
Solution
Thank you. That worked but why did removing the word "Worksheets" and "( )" cause this issue? Thanks.
 
Upvote 0
You're welcome.
Thank you. That worked but why did removing the word "Worksheets" and "( )" cause this issue? Thanks.

Because Worksheets("WO Report Summary 4.0") is an Object, whereas you needed the name of the Object. i.e. Worksheets("WO Report Summary 4.0").Name or more sensibly just "WO Report Summary 4.0"
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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
Back
Top