Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding and naming Excel Worksheets

Posted on 1998-12-03
4
Medium Priority
?
129 Views
Last Modified: 2010-05-03
I need a macro that adds a new sheet in excel and uses a cell to name it. It should be possible to do this as many times as possible.
0
Comment
Question by:panikos
[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
  • 2
4 Comments
 
LVL 2

Expert Comment

by:cartti
ID: 1448083
Use this example as the basis of your macro:

Sub Add_Sheet()
    Sheets.Add().Name = Sheets(1).Range("A1").Value
End Sub
0
 

Author Comment

by:panikos
ID: 1448084
Returns an error "Object required". Also wouldn't this always look for sheet 1 rather than a sheet that has yet to be created.
0
 
LVL 2

Accepted Solution

by:
JiaH earned 300 total points
ID: 1448085
How about this one: (Add the new worksheet at the end of the worksheets and use the first one's A1 as the name, the better one is replace the 1 with it's name such as "Sheet1").

Sheets.Add(, After:=Worksheets(Worksheets.Count)).Name = Sheets(1).Range("A1").Value

0
 
LVL 2

Expert Comment

by:cartti
ID: 1448086
Regarding panikos's comment: What the code does is add a sheet calling it the name you have put in sheet 1, cell A1. What version of Excel have you ?

Regarding JiaH's answer: Besides being a ripoff of my answer, if panikos had problems syntaxly with my example, I find it hard to believe panikos will have any luck with yours
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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