macro for excel

thor10

New Member
Joined
Mar 27, 2002
Messages
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!!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Best way to learn is to record your steps.
On 2002-03-28 13:25, thor10 wrote:
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!!
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,525
Members
448,969
Latest member
mirek8991

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top