Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mdma
 
Posts: n/a
Default IF protection then skip sub.


i have an excel document, that works fine and produces another file
based on the template.

On open of the original document, i have a macro to go and clear any
data in particular cells.

When creating the new file, in my macro I have set the new workbook to
be protected; however when this file is open, it goes and runs the
clear function. This gives an error as it can not clear the cells
due to the protection.

I dont want to turn the protection off, so is there anyway I can check
for protection, if protection is found, then dont run the clear code,

Thanks.


--
mdma
------------------------------------------------------------------------
mdma's Profile: http://www.excelforum.com/member.php...o&userid=24284
View this thread: http://www.excelforum.com/showthread...hreadid=536786

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
macropod
 
Posts: n/a
Default IF protection then skip sub.

Hi mdma,

You could try something like:
If ActiveSheet.ProtectContents = True Then Exit Sub
or
If ActiveSheet.ProtectContents = False Then
' the rest of your clearing code goes here
End If

Cheers


"mdma" wrote in message
...

i have an excel document, that works fine and produces another file
based on the template.

On open of the original document, i have a macro to go and clear any
data in particular cells.

When creating the new file, in my macro I have set the new workbook to
be protected; however when this file is open, it goes and runs the
clear function. This gives an error as it can not clear the cells
due to the protection.

I dont want to turn the protection off, so is there anyway I can check
for protection, if protection is found, then dont run the clear code,

Thanks.


--
mdma
------------------------------------------------------------------------
mdma's Profile:

http://www.excelforum.com/member.php...o&userid=24284
View this thread: http://www.excelforum.com/showthread...hreadid=536786



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code error with Protection turned on - help please Fred Excel Discussion (Misc queries) 1 March 17th 06 04:06 PM
An FAQ that never seems to be answered: autofiltering with protection on... JLC Excel Worksheet Functions 1 December 7th 05 06:14 AM
Illinois Personal Information Protection Act [email protected] Excel Worksheet Functions 0 August 16th 05 03:15 AM
workbook protection John New Users to Excel 1 January 22nd 05 12:55 PM
protection on excel forms cben Excel Worksheet Functions 1 December 14th 04 02:23 PM


All times are GMT +1. The time now is 06:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"