Getting an run-time error '450'

croco1

New Member
Joined
Nov 30, 2016
Messages
10
Hi all,

I'm trying to create a macro to clean up all my different Styles in all sheets of my excel, but I'm getting an error '405' (Wrong number of arguments or invalid property assignment). Not sure what I'm doing wrong... Hopefully someone can help me.

Regards,

VBA Code:
Sub Test2()

Dim XWorksheet As Worksheet
Dim XCell As Range
      
   For Each XWorksheet In ThisWorkbook.Worksheets
        For Each XCell In ActiveSheet.Cells
            If XCell.Style = "InputTableHeading 2" Then
                XCell.Style = "InputTableHeading"
            End If
        Next XCell
   Next XWorksheet

End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
The only thing I can see wrong with your code (other than the fact it will take a really long time as you are processing every single cell) is that you should be using XWorksheet rather than ActiveSheet in your loop.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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