Some Macros does not work when sheet is protected

refer94

New Member
Joined
Feb 15, 2018
Messages
2
Hello all,

I'm currently working on my thesis, i have about 2 weeks left before i have to hand it in. The problem lays within my macros. I have 5 macros in my sheet, when i protect the sheets, they stop working, all except 1 which is a simple print macro. I will post the macro text here, if you need the full sheet please say so. The reason some of the macros are alike is because i work in both Danish and English excel, but excel can't translate properly.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub PressureDrop_Loop_dk()
'
' PressureDrop_Loop_dk Makro
'


'
SolverReset
SolverAdd CellRef:="$BX$21", Relation:=1, FormulaText:="$BS$16"
SolverAdd CellRef:="$BX$21", Relation:=3, FormulaText:="$BS$17"
SolverAdd CellRef:="$BX$22", Relation:=1, FormulaText:="$BS$16"
SolverAdd CellRef:="$BX$22", Relation:=3, FormulaText:="$BS$17"
SolverAdd CellRef:="$BX$23", Relation:=1, FormulaText:="$BS$16"
SolverAdd CellRef:="$BX$23", Relation:=3, FormulaText:="$BS$17"
SolverOk SetCell:="$BX$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$BX$21:$BX$23" _
, Engine:=1, EngineDesc:="GRG ikke-line¾r"
SolverSolve userFinish:=True
End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub PressureDrop_Loop_eng()
'
' PressureDrop_Loop_eng Macro
'


SolverReset
SolverOk SetCell:="$BX$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$BX$21:$BX$23" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$BX$21", Relation:=1, FormulaText:="$BS$16"
SolverOk SetCell:="$BX$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$BX$21:$BX$23" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$BX$21", Relation:=3, FormulaText:="$BS$17"
SolverAdd CellRef:="$BX$22", Relation:=1, FormulaText:="$BS$16"
SolverAdd CellRef:="$BX$22", Relation:=3, FormulaText:="$BS$17"
SolverAdd CellRef:="$BX$23", Relation:=1, FormulaText:="$BS$16"
SolverAdd CellRef:="$BX$23", Relation:=3, FormulaText:="$BS$17"
SolverOk SetCell:="$BX$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$BX$21:$BX$23" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$BX$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$BX$21:$BX$23" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve userFinish:=True
End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Sub PressureDrop_Parallel_dk()
'
' PressureDrop_Parallel_dk Makro
'


'
SolverReset
SolverAdd CellRef:="$BN$5", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BN$6", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BN$7", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BN$8", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BL$4", Relation:=1, FormulaText:="$BL$10"
SolverAdd CellRef:="$BL$4", Relation:=3, FormulaText:="$BL$11"
SolverAdd CellRef:="$BL$5", Relation:=1, FormulaText:="$BL$12"
SolverAdd CellRef:="$BL$5", Relation:=3, FormulaText:="$BL$13"
SolverAdd CellRef:="$BL$6", Relation:=1, FormulaText:="$BL$14"
SolverAdd CellRef:="$BL$6", Relation:=3, FormulaText:="$BL$15"
SolverAdd CellRef:="$BL$7", Relation:=1, FormulaText:="$BL$16"
SolverAdd CellRef:="$BL$7", Relation:=3, FormulaText:="$BL$17"
SolverOk SetCell:="$BN$4", MaxMinVal:=3, ValueOf:=0, ByChange:="$BL$4:$BL$7", _
Engine:=1, EngineDesc:="GRG ikke-line¾r"
SolverSolve userFinish:=True
End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub PressureDrop_Parallel_eng()
'
' PressureDrop_Parallel_eng Macro
'


'
SolverReset
SolverOk SetCell:="$BN$4", MaxMinVal:=3, ValueOf:=0, ByChange:="$BL$4:$BL$7", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$BN$5", Relation:=2, FormulaText:="0"
SolverOk SetCell:="$BN$4", MaxMinVal:=3, ValueOf:=0, ByChange:="$BL$4:$BL$7", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$BN$6", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BN$7", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BN$8", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$BL$4", Relation:=1, FormulaText:="$BL$10"
SolverAdd CellRef:="$BL$4", Relation:=3, FormulaText:="$BL$11"
SolverAdd CellRef:="$BL$5", Relation:=1, FormulaText:="$BL$12"
SolverAdd CellRef:="$BL$5", Relation:=3, FormulaText:="$BL$13"
SolverAdd CellRef:="$BL$6", Relation:=1, FormulaText:="$BL$14"
SolverAdd CellRef:="$BL$6", Relation:=3, FormulaText:="$BL$15"
SolverAdd CellRef:="$BL$7", Relation:=1, FormulaText:="$BL$16"
SolverAdd CellRef:="$BL$7", Relation:=3, FormulaText:="$BL$17"
SolverOk SetCell:="$BN$4", MaxMinVal:=3, ValueOf:=0, ByChange:="$BL$4:$BL$7", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$BN$4", MaxMinVal:=3, ValueOf:=0, ByChange:="$BL$4:$BL$7", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve userFinish:=True

End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub PrintMultipleWorksheets()
'
'Prints TitlePage and PrintPage
'
Worksheets(Array("TitlePage", "PrintPage")).PrintOut


End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Is there a reason you can't unprotect the sheets and reset the protection at the beginning and end of the macro?
 
Upvote 0
Is there a reason you can't unprotect the sheets and reset the protection at the beginning and end of the macro?

I did some research online and tried all other solutions, this should not be the problem, but i just tried it now, and it seems to work now. Thanks for the quick reply :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top