+ Reply to Thread
Results 1 to 3 of 3

Load PageBreaks for a Range in an Array

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Load PageBreaks for a Range in an Array

    Hi Guys,

    I'm trying to figure out if it's possible to load the pagebreaks for a range into an array without looping. Just checking, becuase looping is taking about 20 seconds or so.

    Thanks for any help

    Doesn't Work
    PgBreakRows = Sheet2.[EYIDStart].Resize(61).EntireRow.PageBreak
    Works but takes a second
    c = 0
    For i = 0 To CountofAssets - 1
        ReDim PgBreakRows(c)
        If Sheet2.Rows([EYIDStart].Offset(i).Row).PageBreak <> xlPageBreakNone Then
            PgBreakRows(c) = Sheet2.[EYIDStart].Offset(i).Row
        End If
    Next

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Load PageBreaks for a Range in an Array

    Try this...

        Dim i As Long
        Dim PgBreakRows() As Long
        
        ReDim PgBreakRows(1 To Sheet2.HPageBreaks.Count)
        
        For i = 1 To Sheet2.HPageBreaks.Count
            PgBreakRows(i) = Sheet2.HPageBreaks(i).Location.Row
        Next i
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Load PageBreaks for a Range in an Array

    Very Very Nice! Thank you!

+ 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. Load array from closed workbook range
    By Journeyman3000 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-17-2014, 04:44 PM
  2. Load Values into Array to Compare
    By prescient in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2009, 05:11 PM
  3. Load Contents of array into Range
    By additude in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2008, 07:01 PM
  4. [SOLVED] Load excel range into multi dimensional array
    By Rishi Dhupar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2006, 11:55 AM
  5. Load an array with Sheet names
    By S G Booth in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-02-2005, 05: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