insert sheet and naming sheet macro

Dan88

Active Member
Joined
Feb 14, 2008
Messages
275
Office Version
  1. 365
Platform
  1. Windows
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
 
wddnld, you are the ABSOLUTE greatest.
THANK YOU VERY MUCH, the code works perfectly to my needs.

Thanks for your time and effort!! Much appreciated. I hope i can learn some more from you in the near future!
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Okay, this may be pushing it. Is there a way that i can edit this vba to only insert the sheet if the corresponding column D says "draw" and for all other inputs it wont insert until the next "draw" is inputted into cell D whatever...?
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,047
Members
449,064
Latest member
scottdog129

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top