VBA: Copy different sheet in same workbook multiple times, naming according to list in cells

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
Try this to solve the hidden sheet issue:
Code:
Sub Copy_Master()
'Modified  7/22/2019  7:33:00 AM  EDT
On Error GoTo M
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Sheets("Start").Cells(Rows.Count, "B").End(xlUp).Row
Sheets("Master").Visible = True
For i = 1 To Lastrow
    Sheets("Master").Copy After:=Sheets(Sheets.Count)
    ActiveSheet.Name = Sheets("Start").Cells(i, "B").Value
Next
Application.ScreenUpdating = True
Sheets("Master").Visible = False
Exit Sub
M:
MsgBox "That sheet name may already be used or you made some mistake"
End Sub
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
If you get a message saying there was a error.
You may be using a duplicate name
No two sheets can have the same name
Or you may be trying to name a sheet a improper name.
Excel does not like some characters in a sheet name.

Like it does not like:


7/7/2019

It will accept
7-7-2019

And there may be more characters it does not like.
 

RichCowell

Board Regular
Joined
Dec 5, 2013
Messages
98
Thanks! Works perfectly again... It's only going to be forenames in the list so shouldn't ever include incomatible characters
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
Thanks! Works perfectly again... It's only going to be forenames in the list so shouldn't ever include incomatible characters
 

Watch MrExcel Video

Forum statistics

Threads
1,100,021
Messages
5,472,044
Members
406,796
Latest member
rebson

This Week's Hot Topics

Top