+ Reply to Thread
Results 1 to 9 of 9

How do I modify current code to limit the number of rows/columns my table of contents do

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    How do I modify current code to limit the number of rows/columns my table of contents do

    This is what I am using now. Currently Sub TOC3. But I would like if my rows would end at like 15 and then move into a new column.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,022

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    Change all your Range references from, for example
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    and use

    Please Login or Register  to view this content.
    in place of "B"

    Then use code like

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    How Do i put iCol=2 in place of B if i've already replaced B to be TOC.Cells(NewRow, iCol)

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,022

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    Sorry, that was poorly worded.

    Once you have changed to TOC.Cells(NewRow, iCol), you need to initialize iCol so that the code will start populating in column B of TOC, so you need to add the line

    iCol = 2

    Somewhere in your code before you start using it to address cells within the TOC. So maybe right after the line

    Const StartRow As Long = 5
    iCol = 2

    You can also, then, change

    TOC.Cells(StartRow - 2, "B")

    to

    TOC.Cells(StartRow - 2, iCol)

  5. #5
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    I did, and received a compile error.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,022

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    Before you use a variable, you need to dimension it, since you are using "Option Explicit" at the top of your module. Honestly, given your code to this point, I'm surprised you weren't aware of that as a source of error.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    Ha, that is because I am standing on the shoulder of giants. (google)

  8. #8
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    OK I did. but I still have 36 rows of data. It didn't separate them. It didn't give me an error either though.

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,022

    Re: How do I modify current code to limit the number of rows/columns my table of contents

    Using the button for charts put an ugly doubled text look on a cell - to get around that, I used the selection change event of the workbook.

    Put this into the codemodule of the ThisWorkbook object

    Please Login or Register  to view this content.
    And use this code.

    Please Login or Register  to view this content.

+ 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. Replies: 4
    Last Post: 12-15-2015, 08:59 PM
  2. Limit the number of rows in a pivot table
    By khannar62 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-10-2015, 08:04 PM
  3. Is there a limit to number of columns in a Pivot Table?
    By SEMMatt in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-13-2014, 09:21 PM
  4. [SOLVED] Modify code to transpose a stack of data to rows on to delimit on text hone number field
    By coachtim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2012, 02:52 PM
  5. Modify code to hide rows based on the contents in a cell.
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2009, 09:07 PM
  6. Replies: 1
    Last Post: 11-22-2005, 04:45 PM
  7. [SOLVED] How do I limit number of rows and columns on a spreadsheet
    By Valser in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 02-12-2005, 07:06 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