Hi all.
I am using a macro to insert a sheet to the end of workbook. Is there a code for me to name this sheet based on the value in column B that i have on another sheet named "details".
so if insert sheet and the values in "details" sheet's B1 is THANKYOU, my newly inserted sheet will be named THANKYOU.
B1 is not a static field, meaning i need the macro to read the latest info in column B before it names the new sheet.
Thanks in advance for advice.
Macro im using:
Sub Copy2End()
Dim ShName As String
Dim usrName As String, Authorized As Boolean
usrName = Environ("username")
If (usrName = "Sangdan") Or (usrName = "taylpe") Or (usrName = "sangdan") Or (usrName = "Taylpe") Then '
Authorized = True
Else
Authorized = False
End If
If Authorized Then
Dim ws As Worksheet, WB As Workbook
Set WB = ActiveWorkbook
Set ws = WB.Sheets("Template")
ws.Copy After:=Sheets(WB.Sheets.Count)
End If
End Sub
I am using a macro to insert a sheet to the end of workbook. Is there a code for me to name this sheet based on the value in column B that i have on another sheet named "details".
so if insert sheet and the values in "details" sheet's B1 is THANKYOU, my newly inserted sheet will be named THANKYOU.
B1 is not a static field, meaning i need the macro to read the latest info in column B before it names the new sheet.
Thanks in advance for advice.
Macro im using:
Sub Copy2End()
Dim ShName As String
Dim usrName As String, Authorized As Boolean
usrName = Environ("username")
If (usrName = "Sangdan") Or (usrName = "taylpe") Or (usrName = "sangdan") Or (usrName = "Taylpe") Then '
Authorized = True
Else
Authorized = False
End If
If Authorized Then
Dim ws As Worksheet, WB As Workbook
Set WB = ActiveWorkbook
Set ws = WB.Sheets("Template")
ws.Copy After:=Sheets(WB.Sheets.Count)
End If
End Sub