+ Reply to Thread
Results 1 to 3 of 3

Getting Macro to reference newly created sheet

  1. #1
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Getting Macro to reference newly created sheet

    Hello guys - i am new to this forum and also macros. I have a workbook I created that has a macro to copy the contents of one particular sheet to a new sheet and rename it. The macro also clears out certain data so it can be entered again with the updated information. The problem I am having is getting the macro to run from the newly created sheet and reference that sheet instead of the first sheet. Also I would like the macro to work like: sheet 2 references sheet 1, sheet 3 will reference sheet 2, sheet 4 will reference sheet 3 and so on. Any help would be appreciated. This is the macro I have so far.

    Sub ADDNEWBITRUN()
    '
    ' ADDNEWBITRUN Macro
    '

    '
    ActiveSheet.Unprotect
    Sheets("BITRUN 1").Select
    Sheets("BITRUN 1").Copy Before:=Sheets(6)
    Range("I12").Select
    ActiveCell.FormulaR1C1 = "='BITRUN 1'!R[2]C"
    Range("I11").Select
    Selection.ClearContents
    Range("I13").Select
    Selection.ClearContents
    Range("I16").Select
    Selection.ClearContents
    Range("I18").Select
    ActiveCell.FormulaR1C1 = "='BITRUN 1'!R[1]C"
    Range("I19").Select
    Selection.ClearContents
    Range("I22").Select
    ActiveCell.FormulaR1C1 = "='BITRUN 1'!R[1]C"
    Range("I23").Select
    Selection.ClearContents
    Range("J8").Select
    ActiveCell.FormulaR1C1 = "='BITRUN 1'!RC+1"
    Range("J9").Select
    ActiveWindow.SmallScroll Down:=3
    Range("I38:I42").Select
    Selection.ClearContents
    Range("D39:D41").Select
    Selection.ClearContents
    ActiveWindow.SmallScroll Down:=12
    Range("B45:J52").Select
    Selection.ClearContents
    Range("G20:H20").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("D21").Select
    ActiveSheet.Name = "BITRUN " & Format(Range("J8"))
    End Sub

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Getting Macro to reference newly created sheet

    Hello creuther and welcome to the forum.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Registered User
    Join Date
    12-17-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Getting Macro to reference newly created sheet

    Sorry about not sending the post properly - hopefully this is the correct way:

    Hello guys - i am new to this forum and also macros. I have a workbook I created that has a macro to copy the contents of one particular sheet to a new sheet and rename it. The macro also clears out certain data so it can be entered again with the updated information. The problem I am having is getting the macro to run from the newly created sheet and reference that sheet instead of the first sheet. Also I would like the macro to work like: sheet 2 references sheet 1, sheet 3 will reference sheet 2, sheet 4 will reference sheet 3 and so on. Any help would be appreciated. This is the macro I have so far.


    Please Login or Register  to view this content.

    Thankyou very much.

+ 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