satyen
03-22-2010, 08:16 AM
I am writing a CASE statement to delete contents and unhide rows in certain sheets.
Coming up with an error once it completes. “Object Variable or With Block Variable not set”
Can anyone help please?
Sub test()
Dim Sh As Worksheet
For Each Sh In ActiveWorkbook.Worksheets
Select Case Sh.Name
Case "a", "b", "b"
Cells.Select
Selection.Delete Shift:=xlUp
Selection.EntireRow.Hidden = False
ActiveSheet.Next.Select
Debug.Print Sh.Name
End Select
Next Sh
End Sub
Coming up with an error once it completes. “Object Variable or With Block Variable not set”
Can anyone help please?
Sub test()
Dim Sh As Worksheet
For Each Sh In ActiveWorkbook.Worksheets
Select Case Sh.Name
Case "a", "b", "b"
Cells.Select
Selection.Delete Shift:=xlUp
Selection.EntireRow.Hidden = False
ActiveSheet.Next.Select
Debug.Print Sh.Name
End Select
Next Sh
End Sub