O
oberon.black
I have a worksheet in my workbook that is used as a master copy. I hav
a macro that creates new worksheets based on this worksheet. I want t
hide the master worksheet so that it can not be seen an therefore i
less likly to be altered. However when I hide this sheet all of th
copies that are made from this sheet also hide.
Is there a way or a code that will allow me to hide this sheet bu
still allow the copies that are made from it to be visible?
I would really like to know. I am learning vba as I go so if this is
stupid or easy question don't hammer me to hard about it
This is the code I am using to create and copy my worksheet from
Code
-------------------
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim newSheetName As String
Set ws = Worksheets("CGS")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.LstNm.Value) = "" Then
Me.LstNm.SetFocus
MsgBox "Please enter last name"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.LstNm.Value
ws.Cells(iRow, 2).Value = Me.FrstNm.Value
newSheetName = ws.Cells(iRow, 1) & "," & ws.Cells(iRow, 2)
'clear the data
Me.LstNm.Value = ""
Me.FrstNm.Value = ""
Me.LstNm.SetFocus
For Each ws In Worksheets
If ws.Name = newSheetName Or _
newSheetName = "" Or _
IsNumeric(newSheetName) Then
MsgBox "Sheet already exists or name is invalid", vbInformation
Exit Sub
End If
Next
Sheets("SS").Copy before:=Sheets(1)
Sheets(1).Name = newSheetName
Sheets(newSheetName).Move After:=Sheets(Sheets.Count)
'close userform
Unload Me
End Sub
a macro that creates new worksheets based on this worksheet. I want t
hide the master worksheet so that it can not be seen an therefore i
less likly to be altered. However when I hide this sheet all of th
copies that are made from this sheet also hide.
Is there a way or a code that will allow me to hide this sheet bu
still allow the copies that are made from it to be visible?
I would really like to know. I am learning vba as I go so if this is
stupid or easy question don't hammer me to hard about it
This is the code I am using to create and copy my worksheet from
Code
-------------------
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim newSheetName As String
Set ws = Worksheets("CGS")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.LstNm.Value) = "" Then
Me.LstNm.SetFocus
MsgBox "Please enter last name"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.LstNm.Value
ws.Cells(iRow, 2).Value = Me.FrstNm.Value
newSheetName = ws.Cells(iRow, 1) & "," & ws.Cells(iRow, 2)
'clear the data
Me.LstNm.Value = ""
Me.FrstNm.Value = ""
Me.LstNm.SetFocus
For Each ws In Worksheets
If ws.Name = newSheetName Or _
newSheetName = "" Or _
IsNumeric(newSheetName) Then
MsgBox "Sheet already exists or name is invalid", vbInformation
Exit Sub
End If
Next
Sheets("SS").Copy before:=Sheets(1)
Sheets(1).Name = newSheetName
Sheets(newSheetName).Move After:=Sheets(Sheets.Count)
'close userform
Unload Me
End Sub