OzGrid

How to create vertical page breaks every X Columns

< Back to Search results

 Category: [Excel]  Demo Available 

How to create vertical page breaks every X Columns

 

Requirement:

 

The user wants to insert vertical page breaks at every 35 columns by a macro when the number of columns in the worksheet is variable?

 

Solution:

 

Code:
Sub test()
    Dim i As Integer
    For i = 35 To Cells.Find("*", [A1], xlValues, , xlByColumns, xlPrevious).Column Step 35
        ActiveSheet.Columns(i).PageBreak = xlPageBreakManual
    Next i
End Sub

 

Taking into account this text, it should still be noted that it is possible to improve what is described by introducing game techniques, a striking example of which is the experience of Desura. But in this case, all this will become more reminiscent of the plot of popular addicting games and not what is described initially here.

Obtained from the OzGrid Help Forum.

Solution provided by Daniel.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

 

How to transpose single column into multiple columns and rows
How to create VBA to copy specific column from one sheet to another
How to use a macro or formula to copy data from cell to all cells in that group in adjacent column
How to run a macro if a column has a certain text in it

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)