selecting previously renamed she
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Selecting a Previously ReNamed Sheet

Selecting a Previously ReNamed Sheet

resolvedResolved · High Priority · Version 2003

replyReplyFri 7 Nov 2008, 16:01Delegate Andrew said...

Selecting a Previously ReNamed Sheet

Hi

I have created a new sheet (Copied the Template Sheet) and renamed the sheet by using an input box

Dim NewDealName As String
NewDealName = InputBox("Deal Name")
Sheets("Template (2)").Name = NewDealName

If for Example i call this "Transaction 1" in the input box.

How do i then refer back to this sheet again?

I have tried Sheets("NewDealName").Activate

but this does not seem to work

As i want the macro to refer back to the newly created sheet each time a new deal is added e.g. Transaction 2,3,4.....

Many Thanks

For upcoming training course dates see: Pricing & availability

replyReplySun 16 Nov 2008, 19:37Trainer Laura said...

RE: Selecting a Previously ReNamed Sheet

Hi Andrew

Thank you for your VBA question.

You are very close to the answer, but you don't need to put quotes around the variable name. Therefor you could use

Sheets(NewDealName).Activate

I hope that helps. Please let me know how you get on.


Laura GB

replyReplyMon 17 Nov 2008, 15:08Delegate Andrew said...

RE: Selecting a Previously ReNamed Sheet

Laura

This still does not work - i get "Run-time error '9'" each time?

When i am trying to activate this sheet it is part of a different sub - does that make a difference?

e.g. i have called one sub "NewDealSheet" which creates a named sheet with an input box.

I have then called another sub "BreakdownOfDeal"

Then there is a button i have placed in excel which Calls each of these two subs (Macro called "NewDeal!" - but i get the above error each time)

How do you get around this?

thanks

andrew

replyReplyMon 17 Nov 2008, 17:14Trainer Laura said...

RE: Selecting a Previously ReNamed Sheet

Hi Andrew

Yes it will make a difference if you have the two commands in separate subroutines as the variable will have lost its value in the second subroutine.

One possible solution is to make NewDealName a public variable rather than a local to a single subroutine. Move the following line to above all the subroutines in the declaration section of the module.

Dim NewDealName As String

It should now work if you run the second routine straight after the first routine.

Let me know if it works.

Regards

Laura GB

replyReplyMon 17 Nov 2008, 17:31Delegate Andrew said...

RE: Selecting a Previously ReNamed Sheet

Thanks Laura

I had tried making it public, but i was not running it straight after the first sub!

it all works now!

thanks for your help

Andrew

 

 

Please browse our web site to find out more about
excel classes and other Microsoft training courses.

Excel tip:

Change the default location for opening and saving spreadsheets

If you are always opening spreadsheets from and/or saving documents to a specific location that is not My Documents, save time by setting this folder as the default for opening files from and saving files to.

Here's how:
1. Go to Tools - Options.

2. Select the General tab.

3. Enter the pathname of the folder you wish to make the default in the Default File Location box (hint: it will be easier to use Windows Explorer to navigate to this folder, then copy and paste the pathname from the address bar at the top of the Windows Explorer screen).

4. Click OK.

You have now changed the default folder for opening and saving spreadsheets.

View all Excel hints and tips

forum postIf you are using a resource pool but add resources to an indviduall project, it updates the resource pool aswell, how can you stop this

» Forum post: Shared resources


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training