Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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 Befo=.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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Page Break Adjustments causes a page break each cell BKaufman Excel Worksheet Functions 2 September 10th 10 05:02 AM
Page Break Macro Crowbar Excel Programming 1 November 22nd 05 10:08 PM
Page Break Macro Daniel R. Young Excel Programming 5 July 26th 05 09:17 PM
Using macro for page break Sara Excel Discussion (Misc queries) 2 January 13th 05 09:29 PM
Page break macro lehigh46 Excel Worksheet Functions 2 November 17th 04 02:00 AM


All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"