Copy Sheet VBA Code To New Sheet Automatically

SGD78

New Member
Joined
Mar 24, 2016
Messages
31
Hello everyone,

I'm working on a workbook that tracks clients, and therefore need to create a new sheet for each new client. Does anyone know of a way to configure excel to copy the sheet vba code of an existing worksheet to a newly added worksheet automatically?

Any assistance on this would be greatly appreciated. Thanks to all in advance.

SGD.
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,770
Office Version
  1. 365
Platform
  1. Windows
It is built into Excel

Right-click Sheet tab
\ select Move or Copy \ check Create a copy \ ok

Sheet and its code is copied :)
 
Last edited:

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,770
Office Version
  1. 365
Platform
  1. Windows
here is a simple way to use VBA to achieve it

This code goes in the sheet module of sheet containing your list of clients
Assumes your cient names are in column A starting in row 2
Add new client in column A (and any other details in other columns)
Double click in client's cell in column A
"ModelSheet" & its code is copied
New named sheet is created

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Row > 1 And Target.Column = 1 Then
        Cancel = True
        On Error Resume Next
        Sheets("ModelSheet").Copy after:=Me
        ActiveSheet.Name = Target
    End If
End Sub
 
Last edited:

SGD78

New Member
Joined
Mar 24, 2016
Messages
31
here is a simple way to use VBA to achieve it

This code goes in the sheet module of sheet containing your list of clients
Assumes your cient names are in column A starting in row 2
Add new client in column A (and any other details in other columns)
Double click in client's cell in column A
"ModelSheet" & its code is copied
New named sheet is created

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Row > 1 And Target.Column = 1 Then
        Cancel = True
        On Error Resume Next
        Sheets("ModelSheet").Copy after:=Me
        ActiveSheet.Name = Target
    End If
End Sub

This worked marvelously. Thanks again for the help Yongle. :)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,334
Messages
5,528,091
Members
409,802
Latest member
joeino

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top