+ Reply to Thread
Results 1 to 5 of 5

VBA to copy master sheet and insert new line on summary sheet with updated formulas

Hybrid View

  1. #1
    Registered User
    Join Date
    01-31-2020
    Location
    Derbyshire, England
    MS-Off Ver
    Office 365
    Posts
    5

    Unhappy VBA to copy master sheet and insert new line on summary sheet with updated formulas

    Hi,

    New to this forum and had a good look through the threads to try and find a solution and I'm sure it is here albeit over several threads but I'm having trouble piecing the VBA together to make this work.

    Background: I'm creating a customer account management database which consists of x1 worksheet per customer which is linked to a master 'Summary' tab for the purposes of seeing at a glance outstanding payments by customer.

    Objective: I've created a Command Button which when pressed I hope to i) copy the "Blank" template, ii) re-name it to the next sequential account number in the "Summary" tab, iii) move the new worksheet to the end, iv) insert a new line on row 6 of the 'Summary' tab for the new worksheet created complete with updated formulas to pull the data through.

    I've created some code and managed to get it all working with the exception that it copies the last worksheet (complete with the customer information) rather than the "Blank" worksheet. To prevent confusion (and to hide my embarrassment, I'm a nube!) I'll not post the code. I have however attached the file.

    Any help on writing the VBA code to achieve the objective would be most appreciated.

    Scott
    Attached Files Attached Files
    Last edited by Scott 2020; 02-11-2020 at 09:53 AM.

  2. #2
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: VBA to copy master sheet and insert new line on summary sheet with updated formulas

    Hey Scott,
    Welcome to ExceForum.
    On the new sheet, do you want to create it with the account number or rather the customer name?
    It is possible to do what you want, but I would suggest to create first an account using a UserForm that after completed, the new account gets updated in the Summary sheet and also creates a new sheet for that customer.
    Let me know and I'll do it for you.
    Also, to protect the blank sheet and use it as a template, you should hide it.
    Cheers,
    Filipe


    * If a reply solved or answered your query/question, you can add reputation to the person by clicking on the * Add Reputation
    * When question is resolved, please mark your thread as SOLVED


    Thanks and regards,
    Filipe Oliveira

  3. #3
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: VBA to copy master sheet and insert new line on summary sheet with updated formulas

    Hi Scott,

    Please check attached file.

    I've added a UserForm when you click on "New Customer" button.

    On the form, you can add all details from new customer but it is not mandatory. If you just click on the "ADD" button, it will create a mew account (1502); add a new sheet with the new account number and copy the formulas to the summary sheet.

    The link for the new created sheet will also be active.

    I took the liberty to create a Conditional Formatting so any customer that is added, the table get formatted as well.

    On the code, I have put some notes of what the code is doing for your future reference and so you can also understand what the code does.

    Don't worry with the blank sheet is it is very hidden to avoid deletion.

    Please let me know if that's what you're looking for.

    Best regards,
    Filipe
    Attached Files Attached Files
    Last edited by pipoliveira; 02-10-2020 at 12:39 PM.

  4. #4
    Registered User
    Join Date
    01-31-2020
    Location
    Derbyshire, England
    MS-Off Ver
    Office 365
    Posts
    5

    Re: VBA to copy master sheet and insert new line on summary sheet with updated formulas

    Filipe, you are a genius! Works a treat. Many thanks for your help

    Regards,
    Scott

  5. #5
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: VBA to copy master sheet and insert new line on summary sheet with updated formulas

    Thanks Scott for the feedback and rep

    Just one more thing, if you want to start a new table without data/accounts, you should add the following code to start the account number on "1501". Change this on the outlined part if you want to start with other numeration (This code to be added on the UserForm_Activate):

    Private Sub UserForm_Activate()
    'Code to start Account Number if table is empty. Account set to start at "1501". Change below this number as desired.
    If Sheets("Summary").Range("A6") = "" Then
        Me.AccountTxB.Caption = "1501"
    ElseIf Sheets("Summary").Range("A6") <> "" Then
        Me.AccountTxB.Caption = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Value + 1
    End If
    
    End Sub
    Best of luck!
    Filipe Oliveira
    Last edited by pipoliveira; 02-11-2020 at 11:11 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 09-15-2014, 01:03 PM
  2. [SOLVED] to insert a master sheet with formulas which can verify other work sheets in it
    By greatairi in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 11-20-2013, 12:36 PM
  3. Insert a row, duplicate a sheet and copy cells to master sheet?
    By Dagoom in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-25-2013, 01:26 AM
  4. Insert and Copy to Multiple Sheets from a Master Sheet
    By mja05d in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-21-2013, 11:52 AM
  5. [SOLVED] Summary sheet - copy cell contents from multiple sheets to one summary sheet
    By jsmity in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 10:32 AM
  6. Create a summary from multiple sheets on a master/summary sheet
    By detribus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2012, 08:04 PM
  7. Replies: 0
    Last Post: 07-25-2012, 09:59 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1