ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear contents of unprotected cells in entire workbook with a macr (https://www.excelbanter.com/excel-programming/333176-clear-contents-unprotected-cells-entire-workbook-macr.html)

FinnGirl

Clear contents of unprotected cells in entire workbook with a macr
 
I am trying to write a macro that will clear the contents of all unprotected
cells for an entire workbook. How would I do this without giving the
absolute cell reference for each of the unprotected cells I want to clear?
(I found samples of code that will clear unprotected cells on the active
worksheet only but haven't been able to figure out how to apply this to all
sheet in the entire workbook.
--
Finn Girl

Tom Ogilvy

Clear contents of unprotected cells in entire workbook with a macr
 
Dim sh as Worksheet
Dim sh1 as Worksheet
Dim rng as Range
Application.ScreenUpdating = False
set sh1 = ActiveSheet
set rng = selection
for each sh in ActiveWorkbook.worksheets
sh.Activate
' code to clear unprotected cells on the active sheet
Next
Sh1.Activate
rng.Select
Application.ScreenUpdating = True

--
Regards,
Tom Ogilvy

"FinnGirl" wrote in message
...
I am trying to write a macro that will clear the contents of all

unprotected
cells for an entire workbook. How would I do this without giving the
absolute cell reference for each of the unprotected cells I want to clear?
(I found samples of code that will clear unprotected cells on the active
worksheet only but haven't been able to figure out how to apply this to

all
sheet in the entire workbook.
--
Finn Girl





All times are GMT +1. The time now is 04:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com