+ Reply to Thread
Results 1 to 7 of 7

Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sheets

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    7

    Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sheets

    I am new to VBA and macros. I posted a similar question in a different thread and then realized it may be more suited for this thread. So my apologies in advance for the duplicate post. Here is a little background and my problem. I use excel to create financial statements and do some valuation analysis. The worksheets are then attached to a written report. Each sheet is titled as Exhibit #, based upon the order in the workbook. Typically the workbooks and the end report have less than 15 exhibits, so it is not a big deal to type in the Exhibit Number in the title cell (usually a2). On occasion l have assignments where the number of worksheets (and exhibits) can be as high as 250. Inevitably, in these situations the order of the exhibits will change and/or new exhibits will be added in the middle of the workbook. Then it becomes time consuming to manually re-title each worksheet.

    I am looking for a way to automate the process so the "Exhibit #" title cells can be automatically created or updated. I tried modifying some VBA code I found online based upon the index function but I failed miserably. Any help is greatly appreciated.

    I attached a sample workbook that I quickly threw together showing how I layout the workbook to give you an idea of what I am trying to do. In each worksheet cell A2 it he exhibit # I am referring to.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sh

    Hello,

    May be with a code like this:

    Please Login or Register  to view this content.

    Hoping that it may help you,

    m
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-26-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sh

    Thanks this works great. The only problem I am having is when I copy your code into my personal macro workbook it no longer functions. Any thoughts?

    Quote Originally Posted by mth View Post
    Hello,

    May be with a code like this:

    Please Login or Register  to view this content.

    Hoping that it may help you,

    m

  4. #4
    Registered User
    Join Date
    08-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sh

    Hello,

    I'm really sorry but I don't understand why it doesn't work with your other file. I think it would help us to know where the macros stops, wich line is higlighted ?

    A track could be the first line "Option Explicit".
    With this option, you have to declare all the variables (an exemple here)
    May be you could try without this line, if it works then good (but I think it would be better to declare all the variables of your project and work with this Option Explicit)

    See you soon,

    m

  5. #5
    Registered User
    Join Date
    09-26-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sh

    Thanks. When I copy it into my personal macro workbook, it only changes the first sheet.

  6. #6
    Registered User
    Join Date
    08-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sh

    Well, this seems strange and I don't understand why it stops at the first sheet.

    I'm sorry, and I hope that someone else will help you better then I do !

    So sorry and good luck for your job,

    m

  7. #7
    Registered User
    Join Date
    09-26-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Macro or Function to add a title (ie Exhibit 1) based on worksheet index to muliple sh

    I changed ThisWorkbook to ActiveWorkbook and that seemed to fix the problem.

+ 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