![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 14
|
I would like to write a macro that would sort a column, then insert a page break when the text changes within the sorted column. Your help is greatly appreciated!!
|
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Mar 2002
Location: New York
Posts: 71
|
Best way to learn is to record your steps.
Quote:
|
|
|
|
|
|
|
#3 |
|
Join Date: Mar 2002
Posts: 15
|
Sub Sort_InsertPageBreaks()
Dim rng As Range, cell As Range Set rng = Range([A1], [A65536].End(xlUp)) rng.Sort Key1:=rng(1, 1) For Each cell In rng If cell.Value <> cell(2, 1).Value Then cell(2, 1).EntireRow.PageBreak = xlManual End If Next End Sub |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,064
|
I dont understand the above post and how that answers your request, but the comment is true..
How ever try this.. add a command button from the forms tool bar and right click it and assign macro and then click record.. now do as you wish sortthe data, be careful mistakes are also recorded.. dont worry about the page braek bit.. DONE Now select cell A1, and press the tool bar taht floating about the square stop... Select by right clicking the command button and assign macro BUT edit this time the VBE will open... read it... That the program you just wrote / recorded.. Theres a start for you, if im telling you what you know sorry but your profile is first post, so except sorry just tring to get you started.
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#5 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi
You could try the Subtotals feature under Data. This allows for page breaks at each change. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|