Hi ,
When I try to run the following line of code I get this error:
Runtime error ?424?
Object Required
Public Sub ClearSelectedCells()
Select Case ws.Name This is the line with the error.
What is causing the problem?
Hi ,
When I try to run the following line of code I get this error:
Runtime error ?424?
Object Required
Public Sub ClearSelectedCells()
Select Case ws.Name This is the line with the error.
What is causing the problem?
Hi Austen,
It's most likely a problem with how you have declared/Set your variable 'ws'. Can you post all of the code or at least the portion where you define what 'ws' is? (I'm assuming Worksheet)
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
Public Sub ClearSelectedCells() Dim ws As Double Select Case ws.Name Case "Sheet1" ws.Range("B5:B147", "B20:B22", "B26:B32", "B38:B45", "B49:B52", F1, "F5:F7", "F10:F11").ClearContents 'Case "Sheet2" ' ws.Range("B7:B15", B17, "B21:B36", F1, "F5:F6", "F9:F10").ClearContents 'Case "Sheet3" ' ws.Range("A9:E37", "G9:J37", "K9:L37", "E1:E2", L2).ClearContents 'Case "Sheet4" ' ws.Range("B17:B20", "B25:B28", "C4:C5", C7, "C9:C13", "C31:C36", "E17:E20", G18, "H4:H5", J15).ClearContents End Select End Sub
Ah, ok. You have ws as Double where it needs to be an Object, usually done like ...
orDim ws As Worksheet
Do you already have a loop setup to go through each sheet, or is this all of your code? (Again, assuming you want to go through each sheet.)Dim ws As Object
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables