View Single Post
  #5   Report Post  
SMac
 
Posts: n/a
Default

Sweet!!!! 2 for 2, that was a lot more complicated then I was trying to do.
Thanks for your time!

"Dave Peterson" wrote:

What happens if the value in K8 already has a worksheet associated with it?

Option Explicit
Sub testme02()
Dim myStr As String
Dim iCtr As Long
With ActiveSheet
myStr = .Range("K8").Value
If Trim(myStr) < "" Then
On Error Resume Next
.Name = myStr
If Err.Number < 0 Then
MsgBox "Duplicate Asset in K8--fix and try again"
Err.Clear
End If
On Error GoTo 0
Else
myStr = "Need Asset #-"
iCtr = 1
Do
On Error Resume Next
.Name = myStr & iCtr
If Err.Number = 0 Then
'get out
Exit Do
Else
iCtr = iCtr + 1
Err.Clear
End If
Loop
On Error GoTo 0
End If
End With
End Sub



SMac wrote:

Worked like a charm!!

I have another question for you, on this form there is another command
button "Save Form" which I would like it to take data from cell K8 and use
that as the tab name, if there isn't a name to use "Need Asset #-1" but if
there is already an "Need Asset #-1" make the next one +1 "Need Asset #-2".

Sounds like a messy way but when this form is first filled out there isn't
an Asset # assigned until its been approved by all directors then #'s are
assigned.

Thanks again!!

"Dave Peterson" wrote:

Password protect the worksheet Template.

Then unprotect the copy:

Option Explicit
Sub NewForm2()
Sheets("Template").Copy After:=Sheets(1)
ActiveSheet.Unprotect Password:="hi"
End Sub




???? wrote:

I have a worksheet that the first tab is the template named "Template", what
I want to happen is I have a command button on the form called "New Entry"
which copies the tab and makes "Template (2)" but thinking ahead some people
may forget to hit the command button and start entering into the original
template.
I tried to just lock the sheet but then the lock carries over to the copied
template.

My current code is:

Sub NewForm()
Sheets("Template").Select
Sheets("Template").Copy After:=Sheets(1)
End Sub

Could I add some code at the end to tell the copy to unprotect?

Thanks!!
Stacey

--

Dave Peterson


--

Dave Peterson