Solved

Copy a worksheet & rename from cell value

Posted on 2015-01-17
6
82 Views
Last Modified: 2015-01-19
Hello Experts,

I'd like a macro to:
1)  copy the current worksheet to the end of the workbook  (number of worksheets is variable)
2a) Use the name from N1:T1 cell (a merged field) to rename the worksheet
2b) if the worksheet name is already used, append 1 or 2 or 3 etc.

A sample file is attached.

Thanks
InfoBook.xlsx
0
Comment
Question by:bikeski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 48

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40555892
You can use this macro.

Sub AddSheet()

    Dim lngSheets As Long
    Dim intCount As Integer
    
    ActiveSheet.Copy After:=Sheets(Sheets.Count)
    
    For lngSheets = 1 To Sheets.Count
        If Left$(Sheets(lngSheets).Name, Len(Range("N1"))) = Range("N1") Then
            intCount = intCount + 1
        End If
    Next
    If intCount > 0 Then
        ActiveSheet.Name = Range("N1") & intCount
    Else
        ActiveSheet.Name = Range("N1")
    End If
       
End Sub

Open in new window

0
 

Author Closing Comment

by:bikeski
ID: 40558551
Thanks Martin, works great!
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40558580
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bikeski
ID: 40558656
Martin, You did as I asked. After applying the macro to several worksheets, I realized I needed to copy everything except the formulas, there I only want the numbers. Let me know how you'd like to proceed, I can open a new question?
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40558678
Sure. Let me know when you've added the question.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question