macro to copy and name a sheet

Fraserkitchell

New Member
Joined
May 21, 2010
Messages
47
I was hoping to get some help with a macro. I need to copy a master sheet and create a number of new sheets equal to the number of items in a list.

Thus, if I have five buildings

Building A
Building B
Building C
Building D
Building E

The macro would create five sheets, named "Building A", "Building B", etc. Each sheet would be the same as a master sheet.

I think this is doable...

Thanks,

Fraser
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try

Code:
Sub Master()
Dim LR As Long, i As Long, j As Long
With Sheets("Meter and Buildings")
    LR = Range("B" & Rows.Count).End(xlUp).Row
    For i = 5 To LR
        .Copy after:=Sheets.Count
        ActiveSheet.Name = .Range("B" & i).Value
    Next i
End With
End Sub
 
Upvote 0
Thank you very much. This is not quite working for me yet.

the macro stops aT

.Copy after:=Sheets.Count

with the error message

run time error '1004':

Copy method of Worksheet class failed

Any ideas?
 
Upvote 0
Sorry, it should be

Code:
Sub Master()
Dim LR As Long, i As Long, j As Long
With Sheets("Meter and Buildings")
    LR = .Range("B" & Rows.Count).End(xlUp).Row
    For i = 5 To LR
        .Copy after:=Sheets(Sheets.Count)
        ActiveSheet.Name = .Range("B" & i).Value
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,161
Messages
6,123,375
Members
449,098
Latest member
Jabe

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