VBA duplicate Workbook with sheet names from list

MacroNobie

New Member
Joined
Mar 29, 2018
Messages
12
Hi everybody, I am working on a dashboard, I have a finished one for a specific region and know I want to replicate that workbook but have the sheet name with the region changed so for example this workbook has: Directory, Region 1, Data. I would like to copy it and have: Directory, Region 2, Data.

Is there a way? Thanks for the help!!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Code:
Public Sub SaveAsNewRegion()
Dim vNum, vName
Dim sht As Worksheet


vNum = InputBox("Enter Region#", "Save As New Region Workbook")
If vNum = "" Then Exit Sub


For Each sht In Worksheets
  If InStr(sht.Name, "Region") > 0 Then
     vName = "Region " & vNum
     sht.Name = vName
     ActiveWorkbook.SaveAs "Workbook_" & vName & ".xlsx"
     Exit Sub
  End If
Next
End Sub
 
Upvote 0
Another option
Code:
Sub NewWbk()

   Dim Ws As Worksheet
   Dim Fname As String
   For Each Ws In Worksheets
      If Ws.Name Like "Region*" Then
         Ws.Name = "Region " & Right(Ws.Name, 1) + 1
         Fname = Ws.Name
         Exit For
      End If
   Next Ws
   ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\" & Fname, 52
End Sub
 
Upvote 0
Neither code change any colours.
What do you mean by background colour? & how does it change?
 
Upvote 0
If you are using non standard colours, then you will probably have to reset those colours in the new book. But that is something I know nothing about.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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