+ Reply to Thread
Results 1 to 2 of 2

Page break Macro

  1. #1
    Gaz
    Guest

    Page break Macro

    Hi Experts

    I have have data as below

    CD01A01
    CD22B10
    CE10E01
    CE15X02
    CF16S01

    I need a macro that will insert a page break when the second letter changes i.
    e. CD items will be on one sheet, CE's will be on another etc

    Regards Gaz

    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...mming/200511/1

  2. #2
    Dave Peterson
    Guest

    Re: Page break Macro

    Something like this?

    Option Explicit
    Sub testme01()

    Dim iRow As Long
    Dim FirstRow As Long
    Dim LastRow As Long

    With ActiveSheet
    FirstRow = 2
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    For iRow = FirstRow To LastRow
    If LCase(Left(.Cells(iRow, "A").Value, 2)) _
    = LCase(Left(.Cells(iRow + 1, "A").Value, 2)) Then
    'do nothing
    Else
    .HPageBreaks.Add Before:=.Cells(iRow + 1, "A")
    End If
    Next iRow
    End With

    End Sub

    I checked the first 2 characters of the cell.

    Gaz wrote:
    >
    > Hi Experts
    >
    > I have have data as below
    >
    > CD01A01
    > CD22B10
    > CE10E01
    > CE15X02
    > CF16S01
    >
    > I need a macro that will insert a page break when the second letter changes i.
    > e. CD items will be on one sheet, CE's will be on another etc
    >
    > Regards Gaz
    >
    > --
    > Message posted via OfficeKB.com
    > http://www.officekb.com/Uwe/Forums.a...mming/200511/1


    --

    Dave Peterson

+ 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