+ Reply to Thread
Results 1 to 11 of 11

Need a small edit for some VBA code that runs a table of contents

  1. #1
    Forum Contributor
    Join Date
    11-26-2008
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    326

    Need a small edit for some VBA code that runs a table of contents

    I have some code in a workbook i am making that gives me an "Auto Updating" table of contents" (TOC).
    It works well, but when I added a "1st page cover" the TOC still shows as the 2nd page. (See worksheet attached)
    I want the TOC page to be the 2nd page, and show as the 2nd page on the TOC
    I also never want the page "Radon" to show in the table of contents.
    Can someone with VBA skills help me with this.
    Any help is very much appreciated!!
    (The wook book is attached)
    Thank you / Richard
    Attached Files Attached Files
    Last edited by AliGW; 01-23-2022 at 11:26 AM. Reason: Original title restored: please don't break another rule by using a vague, generic thread title!

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Need a small edit for some VBA code that runs a table of contents

    Hi there,

    See if the attached workbook does what you need. It uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    11-26-2008
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    326

    Re: Need a small edit for some VBA code that runs a table of contents

    Yes, Thank you so much. I am bad at code so I really appreciate it.
    Can I ask one more thing?
    I will be adding a page at the end of the report i'm working on, that I do not want to show on the TOC,
    I will name it "Radon". It will be the last page. Can that be done? If so, another sample please?
    Thanks again.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Need a small edit for some VBA code that runs a table of contents

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Contributor
    Join Date
    11-26-2008
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    326

    Re: Need a small edit for some VBA code that runs a table of contents

    Greg, I ran into a problem. Can the TOC be page 2? I tried to add a "cover page" and it does not show in order
    as I would like it to.

  6. #6
    Forum Contributor
    Join Date
    11-26-2008
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    326

    Re: Need a small edit for some VBA code that runs a table of contents

    Greg,
    I attached a sample (with your code that I made some changes to)
    One thing that is wrong now is I added a "cover page" as the 1st page, but is does not show
    properly in the TOC (See worksheet). Also, can I make so the last page (the "Radon" page) be
    not included in the TOC??
    Thanks Soooo much for any help you can give.
    Regards / Richard
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Need a small edit for some VBA code that runs a table of contents

    @Richard

    You used this at the end of your code:

    Please Login or Register  to view this content.
    For future reference, it needs to be this:

    Please Login or Register  to view this content.
    [/noparse][/CODE]

    I will correct it for you today, but please make sure that you remember how to do it next time.

    Thread now open to responses.
    Last edited by AliGW; 01-23-2022 at 11:10 AM.

  8. #8
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Need a small edit for some VBA code that runs a table of contents

    Hi there,

    Take a look at the attached version of your workbook and see if it does what you need. It uses the following code:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Need a small edit for some VBA code that runs a table of contents

    Hi again,

    Many thanks for the Reputation increase - much appreciated!

    Glad I was able to help.

    Best regards,

    Greg M

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Need a small edit for some VBA code that runs a table of contents

    Oh, dear ...

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)

  11. #11
    Forum Contributor
    Join Date
    11-26-2008
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    326

    Re: Need a small edit for some VBA code that runs a table of contents

    Are you sure this is still a "Help Fourm"?
    I have never had problems like this in all the years I have used this.

+ 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. [SOLVED] Code runs in small datas but not working perfectly in bigger datas
    By RAJESH SHAH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2021, 10:28 PM
  2. [SOLVED] Edit of code, to end on a different cell after "text code" runs.
    By richard11153 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-25-2019, 02:11 PM
  3. VBA Code Button that runs through Date list Table and Copies onto another table
    By Bisky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2018, 10:26 AM
  4. [SOLVED] Small Edit in Code to Run For 1 Sheet Only
    By loverfellow in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2016, 07:47 AM
  5. [SOLVED] Edit a small code to remove error
    By moonbreakker in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-29-2015, 08:09 AM
  6. [SOLVED] Display current contents of a variable and see how it changes when code runs?
    By beaujolais44 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 12:25 AM
  7. Small editing of vba - a table of contents since the second row
    By Remphan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2013, 07:01 PM

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