praveenpatel421983
New Member
- Joined
- Aug 17, 2017
- Messages
- 41
Hi all,
This forum has always helped me when I get stuck with excel vba. I need help again.
I am trying to copy a worksheet named "Work" as "Job" in same workbook and trying to protect "Job" sheet. I came up to following code and I am stuck. Please help.
Thanks
Praveen
This forum has always helped me when I get stuck with excel vba. I need help again.
I am trying to copy a worksheet named "Work" as "Job" in same workbook and trying to protect "Job" sheet. I came up to following code and I am stuck. Please help.
Code:
Sub RenameSht()
Dim ws As Worksheet
ThisWorkbook.Sheets("Work").Copy After:=ThisWorkbook.Sheets(Sheets.Count)
ActiveSheet.Name = "Job"
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "Job" Then
x = ws.CodeName
y = "Rename1"
ThisWorkbook.VBProject.VBComponents(x).Name = y
End If
Next ws
If y.ProtectContents = False Then
y.Protect "test"
End If
End Sub
Thanks
Praveen
Last edited by a moderator: