Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default solver macros in protected worksheets

I've succesfully built a macro that run 2 solver commands in 2 separate tabs
of the same workbook. However, If I protect the worksheets with passwords,
the solver macros trigger an error message - error in parameters or
contraints. It works if I unprotect and then protect within the macro, but
cannot use it if I really want to put a password. Any alternatives?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default solver macros in protected worksheets

Why does this not work with a password?
You can unprotect/reprotect using the password in the same way as with no
password.

Or unlock just the cells Solver needs to change.

Tim

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" <Gilbert wrote in message
...
I've succesfully built a macro that run 2 solver commands in 2 separate

tabs
of the same workbook. However, If I protect the worksheets with

passwords,
the solver macros trigger an error message - error in parameters or
contraints. It works if I unprotect and then protect within the macro, but
cannot use it if I really want to put a password. Any alternatives?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default solver macros in protected worksheets

Exactly !! Why does this not work? I already tried unlocking cells.
More information may help you find me a solution. The Calcs worksheet has
circular references set with iterations in the calculation options.
This is how the macro looks now.

Sub Macro10()
'
' Macro10 Macro
' Macro recorded 2/16/2006 by Hernandege
'

'
Application.Run "Solver.xla!Auto_Open"
Sheets("Calcs").Select
ActiveSheet.Unprotect
Sheets("INPUT").Select
ActiveSheet.Unprotect
Range("C6").Select
ActiveCell.FormulaR1C1 = "10000"
Sheets("Calcs").Select
Range("A200").Select
SolverOk SetCell:="$C$97", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$89"
SolverSolve
Range("A200").Select
Sheets("INPUT").Select
SolverOk SetCell:="$C$38", MaxMinVal:=1, ValueOf:="0.549999",
ByChange:="$C$6"
SolverSolve
Sheets("INPUT").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("Calcs").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("INPUT").Select
Range("C6").Select
ActiveWindow.SmallScroll Down:=25
End Sub



"Tim Williams" wrote:

Why does this not work with a password?
You can unprotect/reprotect using the password in the same way as with no
password.

Or unlock just the cells Solver needs to change.

Tim

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" <Gilbert wrote in message
...
I've succesfully built a macro that run 2 solver commands in 2 separate

tabs
of the same workbook. However, If I protect the worksheets with

passwords,
the solver macros trigger an error message - error in parameters or
contraints. It works if I unprotect and then protect within the macro, but
cannot use it if I really want to put a password. Any alternatives?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default solver macros in protected worksheets

Your original message said it worked if you unprotected the sheet
within the macro. Using a password is just one additional parameter to
the unprotect/protect methods.

Note you don't have to select a sheet to unprotect it

Sheets("Calcs").Select
ActiveSheet.Unprotect


could just be

Sheets("Calcs").Unprotect


Tim


Gilbert LAC wrote:
Exactly !! Why does this not work? I already tried unlocking cells.
More information may help you find me a solution. The Calcs worksheet has
circular references set with iterations in the calculation options.
This is how the macro looks now.

Sub Macro10()
'
' Macro10 Macro
' Macro recorded 2/16/2006 by Hernandege
'

'
Application.Run "Solver.xla!Auto_Open"
Sheets("Calcs").Select
ActiveSheet.Unprotect
Sheets("INPUT").Select
ActiveSheet.Unprotect
Range("C6").Select
ActiveCell.FormulaR1C1 = "10000"
Sheets("Calcs").Select
Range("A200").Select
SolverOk SetCell:="$C$97", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$89"
SolverSolve
Range("A200").Select
Sheets("INPUT").Select
SolverOk SetCell:="$C$38", MaxMinVal:=1, ValueOf:="0.549999",
ByChange:="$C$6"
SolverSolve
Sheets("INPUT").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("Calcs").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("INPUT").Select
Range("C6").Select
ActiveWindow.SmallScroll Down:=25
End Sub



"Tim Williams" wrote:

Why does this not work with a password?
You can unprotect/reprotect using the password in the same way as with no
password.

Or unlock just the cells Solver needs to change.

Tim

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" <Gilbert wrote in message
...
I've succesfully built a macro that run 2 solver commands in 2 separate

tabs
of the same workbook. However, If I protect the worksheets with

passwords,
the solver macros trigger an error message - error in parameters or
contraints. It works if I unprotect and then protect within the macro, but
cannot use it if I really want to put a password. Any alternatives?





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default solver macros in protected worksheets

Thanks Tim. But how do I include a password so nobody else can unprotect it
later?

"Tim Williams" wrote:

Your original message said it worked if you unprotected the sheet
within the macro. Using a password is just one additional parameter to
the unprotect/protect methods.

Note you don't have to select a sheet to unprotect it

Sheets("Calcs").Select
ActiveSheet.Unprotect


could just be

Sheets("Calcs").Unprotect


Tim


Gilbert LAC wrote:
Exactly !! Why does this not work? I already tried unlocking cells.
More information may help you find me a solution. The Calcs worksheet has
circular references set with iterations in the calculation options.
This is how the macro looks now.

Sub Macro10()
'
' Macro10 Macro
' Macro recorded 2/16/2006 by Hernandege
'

'
Application.Run "Solver.xla!Auto_Open"
Sheets("Calcs").Select
ActiveSheet.Unprotect
Sheets("INPUT").Select
ActiveSheet.Unprotect
Range("C6").Select
ActiveCell.FormulaR1C1 = "10000"
Sheets("Calcs").Select
Range("A200").Select
SolverOk SetCell:="$C$97", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$89"
SolverSolve
Range("A200").Select
Sheets("INPUT").Select
SolverOk SetCell:="$C$38", MaxMinVal:=1, ValueOf:="0.549999",
ByChange:="$C$6"
SolverSolve
Sheets("INPUT").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("Calcs").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("INPUT").Select
Range("C6").Select
ActiveWindow.SmallScroll Down:=25
End Sub



"Tim Williams" wrote:

Why does this not work with a password?
You can unprotect/reprotect using the password in the same way as with no
password.

Or unlock just the cells Solver needs to change.

Tim

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" <Gilbert wrote in message
...
I've succesfully built a macro that run 2 solver commands in 2 separate
tabs
of the same workbook. However, If I protect the worksheets with
passwords,
the solver macros trigger an error message - error in parameters or
contraints. It works if I unprotect and then protect within the macro, but
cannot use it if I really want to put a password. Any alternatives?







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default solver macros in protected worksheets

Activesheet.Protect Password:="YourPassword"

etc.

Since the password is now hard-coded in the VBA project you should also
password-protect that also (though be aware this is protection only against
"casual" interest....)

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" wrote in message
...
Thanks Tim. But how do I include a password so nobody else can unprotect

it
later?

"Tim Williams" wrote:

Your original message said it worked if you unprotected the sheet
within the macro. Using a password is just one additional parameter to
the unprotect/protect methods.

Note you don't have to select a sheet to unprotect it

Sheets("Calcs").Select
ActiveSheet.Unprotect


could just be

Sheets("Calcs").Unprotect


Tim


Gilbert LAC wrote:
Exactly !! Why does this not work? I already tried unlocking cells.
More information may help you find me a solution. The Calcs worksheet

has
circular references set with iterations in the calculation options.
This is how the macro looks now.

Sub Macro10()
'
' Macro10 Macro
' Macro recorded 2/16/2006 by Hernandege
'

'
Application.Run "Solver.xla!Auto_Open"
Sheets("Calcs").Select
ActiveSheet.Unprotect
Sheets("INPUT").Select
ActiveSheet.Unprotect
Range("C6").Select
ActiveCell.FormulaR1C1 = "10000"
Sheets("Calcs").Select
Range("A200").Select
SolverOk SetCell:="$C$97", MaxMinVal:=1, ValueOf:="0",

ByChange:="$C$89"
SolverSolve
Range("A200").Select
Sheets("INPUT").Select
SolverOk SetCell:="$C$38", MaxMinVal:=1, ValueOf:="0.549999",
ByChange:="$C$6"
SolverSolve
Sheets("INPUT").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("Calcs").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("INPUT").Select
Range("C6").Select
ActiveWindow.SmallScroll Down:=25
End Sub



"Tim Williams" wrote:

Why does this not work with a password?
You can unprotect/reprotect using the password in the same way as

with no
password.

Or unlock just the cells Solver needs to change.

Tim

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" <Gilbert wrote in

message
...
I've succesfully built a macro that run 2 solver commands in 2

separate
tabs
of the same workbook. However, If I protect the worksheets with
passwords,
the solver macros trigger an error message - error in parameters

or
contraints. It works if I unprotect and then protect within the

macro, but
cannot use it if I really want to put a password. Any

alternatives?







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default solver macros in protected worksheets

Thanks again.
I'm still curious why the twin solver did not work while protected?
It did when I only had one worksheet solver coded.

"Tim Williams" wrote:

Activesheet.Protect Password:="YourPassword"

etc.

Since the password is now hard-coded in the VBA project you should also
password-protect that also (though be aware this is protection only against
"casual" interest....)

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" wrote in message
...
Thanks Tim. But how do I include a password so nobody else can unprotect

it
later?

"Tim Williams" wrote:

Your original message said it worked if you unprotected the sheet
within the macro. Using a password is just one additional parameter to
the unprotect/protect methods.

Note you don't have to select a sheet to unprotect it

Sheets("Calcs").Select
ActiveSheet.Unprotect

could just be

Sheets("Calcs").Unprotect


Tim


Gilbert LAC wrote:
Exactly !! Why does this not work? I already tried unlocking cells.
More information may help you find me a solution. The Calcs worksheet

has
circular references set with iterations in the calculation options.
This is how the macro looks now.

Sub Macro10()
'
' Macro10 Macro
' Macro recorded 2/16/2006 by Hernandege
'

'
Application.Run "Solver.xla!Auto_Open"
Sheets("Calcs").Select
ActiveSheet.Unprotect
Sheets("INPUT").Select
ActiveSheet.Unprotect
Range("C6").Select
ActiveCell.FormulaR1C1 = "10000"
Sheets("Calcs").Select
Range("A200").Select
SolverOk SetCell:="$C$97", MaxMinVal:=1, ValueOf:="0",

ByChange:="$C$89"
SolverSolve
Range("A200").Select
Sheets("INPUT").Select
SolverOk SetCell:="$C$38", MaxMinVal:=1, ValueOf:="0.549999",
ByChange:="$C$6"
SolverSolve
Sheets("INPUT").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("Calcs").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("INPUT").Select
Range("C6").Select
ActiveWindow.SmallScroll Down:=25
End Sub



"Tim Williams" wrote:

Why does this not work with a password?
You can unprotect/reprotect using the password in the same way as

with no
password.

Or unlock just the cells Solver needs to change.

Tim

--
Tim Williams
Palo Alto, CA


"Gilbert LAC" <Gilbert wrote in

message
...
I've succesfully built a macro that run 2 solver commands in 2

separate
tabs
of the same workbook. However, If I protect the worksheets with
passwords,
the solver macros trigger an error message - error in parameters

or
contraints. It works if I unprotect and then protect within the

macro, but
cannot use it if I really want to put a password. Any

alternatives?








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
Macros, Forms, & Protected Worksheets..... how would I... awadmin Setting up and Configuration of Excel 1 September 13th 09 03:36 AM
Macros with Protected Worksheets Terri Excel Discussion (Misc queries) 1 April 13th 06 06:27 PM
Group, Outline, Protected Worksheets and Protected Workbook BEEJAY Excel Programming 0 February 13th 06 08:40 PM
Help please - how to run Solver in a protected sheet? German[_6_] Excel Programming 4 October 21st 04 06:48 AM
Solver via VBA on protected sheet problem josvr Excel Programming 4 October 2nd 03 02:20 AM


All times are GMT +1. The time now is 09:51 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"