Enabling macros while the sheet being protected !

M

mangesh_yadav

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
 
P

Pank

Dinesh,

Try the following to unprotect the activesheet:-

..unprotect password:="yourpasswordhere"

To protect the sheet try:-

..protect password:="yourpasswordhere"

HTH

Pank
 
D

dinesh

HI,

I AM GETTING THE FOLLOWING ERROR WHEN I RUN THE MACROS WHILE TH
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 tel
me in detail.
*
Have a Nice Day !
Dinesh Vijaywargiay
*:
 
D

Dave Peterson

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

dinesh

UNPROTECTING THE SHEET, RUNNING CODE & AGAIN PROTECTING SHEET..

THAT'S NOT THE SOLUTION.

I REMEMBER THERE IS SOME METHOD OF MODIFYING THE VBA CODE... B
ENTERING THE PASSWORD IN THE CODE... I AM NOT ABLE TO RECAL
 
T

tkaplan

modify the code to unprotect the sheet as the first line of the macr
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 correc
macr
 
D

dinesh

::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 SU

Regards,
Dinesh Vijaywargiay:
 
T

tkaplan

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
 
D

dinesh

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 VIJAYWARGIA
 
T

tkaplan

copy and past the following code as is to replace what you currentl
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 su
 
D

dinesh

AGAIN GETTING THE SAME ERRORS...(COMPILE ERROR: SYNTAX ERROR) & THER
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 MODIF
ALL THE MACROS..

REGARDS,
DINESH VIJAYWARGIA
 
T

tkaplan

when it hightlights sub name(), where does it put the mouse curser or
select the text in blue?
 
D

dominicb

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 th
protection still in place. This will not automatically take effec
every time the workbook is opened, so you would have to tie it to a
event procedure to run it every time the file is used.

HTH

Dominic
 
Top