E
Excel-General
I copy a control worksheet sheet(2) from the active workbook it places
it before the control sheet. I want to change the name of the new
sheet. The last line where I want to assign the name gives me a 1004
runtime error. Can you tell me how to name the sheet? the copied
sheet should now be sheet(2) right? tia,
Sub CpySinglePatientSht()
Dim wb As Workbook
Dim ws As Worksheet
Dim Lname As String
Dim sStr As String
Set wb = ThisWorkbook
wb.Sheets(2).Copy before:=wb.Sheets(2)
'copies the control worksheet and puts the copied sheet in front
of it
Set ws = wb.Sheets(2)
sStr = UserForm1.g_fNameLName
Lname = Mid(sStr, InStr(1, sStr, " ") + 1)
Debug.Print Lname
'parses the FName and LName concatenation into just the Lname and
renames worksheet
wb.Sheets(2).Name = Lname
End Sub
it before the control sheet. I want to change the name of the new
sheet. The last line where I want to assign the name gives me a 1004
runtime error. Can you tell me how to name the sheet? the copied
sheet should now be sheet(2) right? tia,
Sub CpySinglePatientSht()
Dim wb As Workbook
Dim ws As Worksheet
Dim Lname As String
Dim sStr As String
Set wb = ThisWorkbook
wb.Sheets(2).Copy before:=wb.Sheets(2)
'copies the control worksheet and puts the copied sheet in front
of it
Set ws = wb.Sheets(2)
sStr = UserForm1.g_fNameLName
Lname = Mid(sStr, InStr(1, sStr, " ") + 1)
Debug.Print Lname
'parses the FName and LName concatenation into just the Lname and
renames worksheet
wb.Sheets(2).Name = Lname
End Sub