+ Reply to Thread
Results 1 to 5 of 5

Creating a New Sheet with Macros

  1. #1
    Registered User
    Join Date
    01-05-2009
    Location
    Southern Pines, NC
    MS-Off Ver
    Excel 2007
    Posts
    95

    Cool Creating a New Sheet with Macros

    I am working in 2007 and trying to build a macro that will create a new sheet, go back to my original sheet, copy data and paste it on the new sheet. The problem is, that in the macro, it creates a new sheet named “Sheet #”, but when I try to rerun the macro, the new Sheet is named “Sheet #+1”. Therefore, when the macro tries to select the sheet, due to the wrong name, it stops and returns an error message. How do I create a macro that will create a new sheet and then be able to select that sheet to paste info.

    Big Picture, I am trying to create the ability to enter new financials every quarter and keep the old financials. Since the worksheets require quite a bit of formulas, I want a macro that will automatically carry over the formulas. Each quarter, I want to be able to hit a button and it add a new sheet, enter the formulas and formatting so it is ready for me to work on. Please help

    Thanks,

  2. #2
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Creating a New Sheet with Macros

    Hi there

    This might help you on your way. My VBA is not all that great but it seems to allow you to flick between sheets and the newly added sheet.

    Please Login or Register  to view this content.

    Hope this helps

    Jim

    As an adition, it could be worth thinking about having a blank sheet that can just be copied and re-named each time its required.
    Last edited by JimmyA; 01-21-2010 at 05:14 PM.

  3. #3
    Registered User
    Join Date
    01-05-2009
    Location
    Southern Pines, NC
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: Creating a New Sheet with Macros

    I am not very good with VBA. I created my macro by using the record button. Below is what the record button used. What changes should be made?

    I am coping data from “Office Template Prop 61968” to a new worksheet.

    Sub YE_New_Record()
    '
    ' YE_New_Record Macro
    '

    '
    Sheets.Add After:=Sheets(Sheets.Count)
    Sheets("Office Template Prop 61968").Select
    Columns("A:R").Select
    Selection.Copy
    Sheets("Sheet13").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Range("A1").Select
    Sheets("Office Template Prop 61968").Select
    Application.CutCopyMode = False
    Range("A1").Select
    Sheets("Sheet13").Select
    End Sub

  4. #4
    Registered User
    Join Date
    01-05-2009
    Location
    Southern Pines, NC
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: Creating a New Sheet with Macros

    Looking at your language, below are the changes I made, but it stops at: Sheets ("NewW").Select

    Sub YE_New_Record()
    '
    ' YE_New_Record Macro
    '

    '
    Worksheets.Add
    NewW = ActiveSheet.Name
    Sheets("Office Template Prop 61968").Select
    Columns("A:R").Select
    Selection.Copy
    Sheets("NewW").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Range("A1").Select
    Sheets("Office Template Prop 61968").Select
    Application.CutCopyMode = False
    Range("A1").Select
    Sheets("NewW").Select
    End Sub

  5. #5
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Creating a New Sheet with Macros

    Hi

    You need to put this bit at the top the line after
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Hope this helps


    P.S. If you put code in a post you are meant to put code tags round it (so it appears in a box). you do tha by highlighting the code and selecting the "#" icon in the menu. Just thought I would meniton it as i got told off for it it once.
    Last edited by JimmyA; 01-21-2010 at 05:38 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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