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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,215,514
Messages
6,125,263
Members
449,219
Latest member
daynle

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