+ Reply to Thread
Results 1 to 6 of 6

Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    01-10-2012
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    62

    Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

    Hi,

    I am working with the following part of code;

    Machs = Array("Mach-1", "Mach-2", "Mach-3", "Mach-4", "Mach-5", "Mach-6", "Mach-7", _
             "Mach-8", "Mach-9", "Mach-10", "Mach-11", "Mach-12")
    
    For Each Mach In Machs
        If Range("O236") > 0 Then
        Worksheets.Add(After:=Worksheets(1)).Name = "My New Worksheet"
    Next Mach

    What would i replace "My New Worksheet" with to get the current worksheet name (see array above) plus the word "Budget"?


    Thanks

  2. #2
    Registered User
    Join Date
    08-17-2012
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

    Try this -

    sheetname = ActiveSheet.Name
    Worksheets.Add(After:=Worksheets(1)).Name = sheetname & " Budget"

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

    Maybe:

    Sub MICowboy13()
    Machs = Array("Mach-1", "Mach-2", "Mach-3", "Mach-4", "Mach-5", "Mach-6", "Mach-7", _
             "Mach-8", "Mach-9", "Mach-10", "Mach-11", "Mach-12")
    
    For Each Mach In Machs
        If Range("O236") > 0 Then
        Worksheets.Add(After:=Worksheets(1)).name = Mach & " Budget"
    Next Mach
    
    End Sub

  4. #4
    Registered User
    Join Date
    01-10-2012
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

    Reagan.kha,

    Thank you for your response, your solution may have worked but John's made more sense to me so I went with that one.

    John,

    Thanks for your help. If you have a spare moment can you review my code and tell me why it stops after the first worksheet in my array? After running the code it creates a new sheet and names it "Mach-1 Budget" and then nothing else happens. Also the code only works if I run the macro from the sheet named "Mach-1". What am I doing wrong?

    Sub CreateBudgetForm()
    
    'Misc
    Dim Machs As Variant
    Dim Mach As Variant
    
    
    'Loop through sheets
    Machs = Array("Mach-1", "Mach-2", "Mach-3", "Mach-4", "Mach-5", "Mach-6", "Mach-7", _
             "Mach-8", "Mach-9", "Mach-10", "Mach-11", "Mach-12")
    
    For Each Mach In Machs
        If Range("O236") > 0 Then Worksheets.Add(After:=Worksheets(1)).Name = Mach & " Budget"
    Next Mach
    
    End Sub
    Thanks
    Last edited by MICowboy13; 06-12-2015 at 03:45 PM.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

    From what I see Mach should be declared as a worksheet. And Machs should be a Sheets Array. I don't have much time as I'm signing off for the weekend. If you haven't got a solution by Monday, I'll be glad too revisit.

  6. #6
    Registered User
    Join Date
    01-10-2012
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Use Current Worksheet Name in Formula to Rename Newly Created Worksheet

    John,

    Thanks for your help and have a great weekend.

+ 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. Copy Rows by Cell Value, Paste to Newly Created Worksheet, Email Contents
    By TylerK_BLL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-09-2015, 03:40 PM
  2. Replies: 0
    Last Post: 07-16-2013, 01:20 PM
  3. Updating data on newly created worksheet
    By wolverine82 in forum Excel General
    Replies: 6
    Last Post: 04-14-2010, 11:17 AM
  4. macro that will automatically link a newly created worksheet to a summary sheet
    By liquidblack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2009, 03:22 PM
  5. Referencing a newly created worksheet
    By Charyn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2005, 12:07 AM

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