+ Reply to Thread
Results 1 to 14 of 14

Enabling macros while the sheet being protected !

  1. #1
    Registered User
    Join Date
    06-10-2005
    Posts
    10

    Question Enabling macros while the sheet being protected !

    Guys,


    How to run the macros while the sheet is being protected.

    Any ideos.

    Please reply me at [email protected]
    Dinesh Vijaywargiay

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    You can still run macros even if the sheet is being protected. By the way, how are you currently running them. As for you other posts, are you running the web query though a macro, or have you set it up.

    Mangesh

  3. #3
    Pank
    Guest

    Re: Enabling macros while the sheet being protected !

    Dinesh,

    Try the following to unprotect the activesheet:-

    ..unprotect password:="yourpasswordhere"

    To protect the sheet try:-

    ..protect password:="yourpasswordhere"

    HTH

    Pank


    "mangesh_yadav" wrote:

    >
    > You can still run macros even if the sheet is being protected. By the
    > way, how are you currently running them. As for you other posts, are
    > you running the web query though a macro, or have you set it up.
    >
    > Mangesh
    >
    >
    > --
    > mangesh_yadav
    > ------------------------------------------------------------------------
    > mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
    > View this thread: http://www.excelforum.com/showthread...hreadid=377989
    >
    >


  4. #4
    Registered User
    Join Date
    06-10-2005
    Posts
    10
    Hi,

    I am getting the following error when I run the macros while the sheet being protected.

    " Run time error '1004' Sort method of range class failed"


    Actually I am refreshing a web query through macro.


    & dear pank... I don't know where to put the code.. Please tell me in detail.

    Have a Nice Day !
    Dinesh Vijaywargiay

  5. #5
    Dave Peterson
    Guest

    Re: Enabling macros while the sheet being protected !

    How about just unprotecting the worksheet, run your code and reprotect the
    worksheet?

    dinesh wrote:
    >
    > HI,
    >
    > I AM GETTING THE FOLLOWING ERROR WHEN I RUN THE MACROS WHILE THE
    > SHEET BEING PROTECTED.
    > ::-
    > \\" RUN TIME ERROR '1004' SORT METHOD OF RANGE CLASS FAILED\\"
    > -
    >
    > Actually I am refreshing a web query through macro.
    >
    > & dear pank... I don't know where to put the code.. Please tell
    > me in detail.
    > *
    > Have a Nice Day !
    > Dinesh Vijaywargiay
    > *::
    >
    > --
    > dinesh
    >
    > ------------------------------------------------------------------------
    > dinesh's Profile: http://www.excelforum.com/member.php...o&userid=24177
    > View this thread: http://www.excelforum.com/showthread...hreadid=377989


    --

    Dave Peterson

  6. #6
    Registered User
    Join Date
    06-10-2005
    Posts
    10
    Unprotecting the sheet, running code & again protecting sheet..

    That's not the solution.

    I remember there is some method of modifying the VBA code... by entering the password in the code... I am not able to recall

  7. #7
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136
    modify the code to unprotect the sheet as the first line of the macro and protect as the last line. a previous post states that code.

    hit alt+f11 to open the vba window and add the code to the correct macro

  8. #8
    Registered User
    Join Date
    06-10-2005
    Posts
    10
    Thanks kaplan.

    Is that code correct? I am getting some error.

    Can you please modify my code. My code is :

    Sub name()
    '
    ' name Macro
    ' Macro recorded 3/14/2005 by Dinesh
    '
    ' Keyboard Shortcut: Ctrl+q
    '
    Range("A3:az28").Sort Key1:=Range("A4"), Order1:=xlAscending, Header:= _
    xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End Sub


    Regards,
    Dinesh Vijaywargiay

  9. #9
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136
    sub name()

    ..unprotect password:="yourpasswordhere"

    ...the code that is currently there....

    ..protect password:="yourpasswordhere"

    end sub

    make sure you change "yourpasswordhere" to what your password is.

  10. #10
    Registered User
    Join Date
    06-10-2005
    Posts
    10
    I am not getting it... does those two dots need to be there...

    Can you please modify my code...

    I am getting errors like... 'Can't execute in breake mode' 'Identifier or bracketed expression'

    I will fill the password field...

    Regards,
    Dinesh Vijaywargiay

  11. #11
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136
    copy and past the following code as is to replace what you currently have: just change the password field:
    sub name()

    ..unprotect password:="yourpasswordhere"

    Range("A3:az28").Sort Key1:=Range("A4"), Order1:=xlAscending, Header:= _
    xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal

    ..protect password:="yourpasswordhere"

    end sub

  12. #12
    Registered User
    Join Date
    06-10-2005
    Posts
    10
    again getting the same errors...(compile error: syntax error) & there is a yellow highlighting on sub name()

    I have many macros in my sheet.... I am modifying only one macro.. protecting the sheet and running only that macro. Do I need to modify all the macros..

    Regards,
    Dinesh Vijaywargiay

  13. #13
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136
    when it hightlights sub name(), where does it put the mouse curser or select the text in blue?

  14. #14
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening Dinesh

    Why not use this line of code at the start of your module:

    ActiveSheet.Protect UserInterfaceOnly:=True

    This will allow your macro to make changes to your sheet with the protection still in place. This will not automatically take effect every time the workbook is opened, so you would have to tie it to an event procedure to run it every time the file is used.

    HTH

    DominicB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1