Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ClearContents for a range of worksheets

Status
Not open for further replies.

dalex17

Technical User
Jul 14, 2002
96
US
Regarding Microsoft Excel:

I have a code (below) that clears the contents of cell B95 each time the workbook opens.

Range("B95").ClearContents

The problem I am having is that it only clears the cell of the one active worksheet that was last open; each time I re-open the workbook.

Is there a way to clear that cell from all of the worksheets in the workbook, each time the workbook is closed and opened?

Please let me know if I should clarify.

Dalex
 
Sure. Try:

For Each s In Sheets
Range("B95").ClearContents
Next s

Dan.
 
I want to ammend my post above. Try the following modified code instead:

Dim s
For Each s In Worksheets
s.Range("B1").ClearContents
Next s
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top