Resetting a Worksheet

EE Pros,

I have a macro that clears a number of cells through out a workbook.  Here's the slight dilemma.  If I fire the macro, and I have an outline collapsed on another worksheet, it will give me an error message.  For that reason, I need for the macro that clears the cells to "expand the outline" before it clears the results and thus works and won't give me the error on this line:  .Range("E:E") = "".  If I expand the OUTLINE to level 3, it will clear the Worksheet without a problem.  How do I add a line or two of code to auto expand the outline to level 3 before it tries to clear the cells?

Here is what the code looks like.

Sub ClearSelections()
'ActiveSheet.Unprotect Password:="password"
Dim I As Integer
    Application.EnableEvents = False
    Application.ScreenUpdating = False

   With Worksheets("Use_Cases")
   ActiveSheet.Unprotect Password:="password"


.Range("E:E") = ""
.Range("G800:G812") = ""
.Range("H7:H800") = ""
'.Range("r2") = 0
End With
    Application.ScreenUpdating = True
    Application.EnableEvents = True
.Protect Password:="jam"
End With
End Sub
Bright01Asked:
Who is Participating?
 
Rodney EndrigaData AnalystCommented:
Try to insert this bit of code depending on how many levels you have in your Outline:

ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveSheet.Outline.ShowLevels RowLevels:=2
ActiveSheet.Outline.ShowLevels RowLevels:=3

Insert these lines of code before you Clear the worksheet
0
 
Martin LissOlder than dirtCommented:
Create a macro while doing it manually and then include code like you see in the new macro.
0
 
Bright01Author Commented:
Thanks guys..... got it to work based on your comments.

Appreciate the help.

ML; "it's in the mail".

b.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.