Hello Experts,

in the attached workbook, i have two sheets ie template and setup. On the
"setup" sheet, when you enter a text in column B, and click create
template, the macro for that button will always pick the last text in
column B and create a template using the last text entered as the
sheetname. Everything looks perfect in terms of the formating and the
formulas that the macro creates. The issue is that after the template is
created, you may want to prevent users from tampering with the formulas so
i added a bit that should lock the formulas and the worksheet, after the
macro successfully executes this command, all the formulas are turned into
values as such the template becomes cos 90 ie formulas dont work again, pls
is there a way around this. thanks

the password  is "test"



Sub createtemplate()
 Dim strtname As String

strtname = Sheets("SETUP").Range("B" & Rows.Count).End(xlUp)
'option to create sheet
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = strtname
Sheets("SETUP").Select

'option to copy sheet format
 Sheets("template").Select
    Cells.Select
    Selection.Copy
    Sheets(strtname).Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False

'option to paste sheet values and formulas
    Sheets("template").Select
    Cells.Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets(strtname).Select
    Range("A1").Select
    ActiveSheet.Paste

   'protects the worksheet
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveSheet.Protect Password:="test"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True


End Sub

-- 
Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to