Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 22nd, 2005, 04:05 AM
Authorized User
 
Join Date: Jan 2005
Location: Kuala Lumpur, Fed. Territory, Malaysia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Protection and commandButtons

Hi, To all Gurus!

   When I protect a particular worksheet, it includes formulas on certain cells.
    However, when I click a commandbutton the macros should run to change a particular cell to another value, even though a formula like "=Sum(K2+K3)" is laready on that cell.
    This is not the case when Sheet Protection is on. Each time I click on the Commandbutton, it displays this "Sheet is protected".
     How do I go about it to run the procedures attached to the commandbuttons in a protected sheet, as other cells are also required to be protected.
     The answer given by Excel is to unprotect the worksheet, but this will lead to other cells that should be protected becoming unprotected again!
:(
  #2 (permalink)  
Old February 22nd, 2005, 04:29 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You must unprotect your sheet first then change cell and then
protect your sheet again

Sub Code()
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, _ Scenarios:=True
'*** Do some changes here
ActiveSheet.Unprotect
End Sub

  #3 (permalink)  
Old March 1st, 2005, 12:32 AM
Authorized User
 
Join Date: Jan 2005
Location: Kuala Lumpur, Fed. Territory, Malaysia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi! Vemaju,
Sorry for the delay in thanking you.
I found out the same principle as yours earlier on and forgot to return to this forum on time.
 I started off with codes to unprotect the sheet first , then ending it by protecting codes!
   It's good to have someone like you assisting me, but I am not sure whether it's proper for me to ask farther as I am still on the "Commandbutton topic", or shall I post a new topic?
  #4 (permalink)  
Old March 4th, 2005, 09:27 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Bournemouth, Dorset, United Kingdom.
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never be afraid to ask, I always say the only bad type of question is the one not asked.

Matt



Similar Threads
Thread Thread Starter Forum Replies Last Post
DB Protection ~Bean~ SQL Language 4 October 25th, 2005 07:37 AM
Commandbuttons in Reports DaDeViL Access VBA 2 August 19th, 2005 08:13 AM
Protection evad Excel VBA 0 April 26th, 2005 09:06 AM
Active X -Commandbuttons bahachin Excel VBA 4 January 24th, 2005 02:26 PM
Protection level noman77 .NET Framework 2.0 0 October 23rd, 2004 07:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.