Copy Worksheet plus ranges

  • Thread starter Thread starter Ray Batig
  • Start date Start date
R

Ray Batig

Greetings,

I have a workbook that is growing in functionality. One sheet is named
Charley (for discussion). There is a range called Blocks that holds several
entries. First, I need to make one copy of Charlie for each entry in the
Blocks range. I would like the copy placed after Charlie and renamed to
reflect the concatenation of the Block name a space and Charlie. This would
be repeated for each block in the range. The code below generates Charlie(2)
and then gives me a run time error.

What am I doing wrong?

Thanks in advance for your help!

Ray


Sub Copy_Charlie()

Dim Block As Range
Dim SheetNam As String
Dim ModSheetNam As String
Dim ModSheetNam2 As String

SheetNam = "Charlie"
ModSheetNam = SheetNam

For Each Block In Range("Blocks")
ModSheetNam2 = Block.Value + " " + SheetNam

Worksheets(SheetNam).Copy(after:=Worksheets(ModSheetNam)).Name _
= ModSheetNam2

ModSheetNam = ModSheetNam2

Next
End Sub
 
Change this line:

Worksheets(SheetNam).Copy(after:=Worksheets(ModSheetNam)).Name _
= ModSheetNam2

to

Worksheets(SheetNam).Copy after:=Worksheets(ModSheetNam)
Activesheet.Name = ModSheetNam2


Regards
Rowan
 
Works great! Looks like I was trying to do too many things in one step.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top