Very impressed and thanks!
Kutools for Excel is a powerful add-in that frees you from performing time-consuming operations in Excel, such as combine sheets quickly, merge cells without losing data, paste to only visible cells, count cells by color and so on. 300+ powerful features / functions for Excel 2019, 2016, 2013, 2010, 2007 or Office 365!
It enables tabbed browsing, editing, and managing of Microsoft Office applications. You can open multiple documents / files in a single tabbed window, such as using the browser IE 8/9/10, Firefox, and Google Chrome. It's compatible with Office 2019, 2016, 2013, 2010, 2007, 2003 or Office 365. Demo
Kutools for Outlook is a powerful add-in that frees you from time-consuming operations which majority of Outlook users has to perform daily! It can save your time from using Microsoft Outlook 2019, 2016, 2013, 2010 or Office 365!
Kutools for Word is a powerful add-in that frees you from time-consuming operations which majority of Word users have to perform daily! It can save your time from using Microsoft Word / Office 2019, 2016, 2013, 2010, 2007, 2003 or Office 365!
Restores the old look and menus of Office 2003 to Microsoft Office 2019, 2016, 2013, 2010, 2007 or Office 365. Don’t lose time in finding commands on the new Ribbon. Easy to deploy to all computers in enterprises and organizations.
Supposing, I have a range of cells, and now, I want to insert page breaks into the worksheet when values in column A changes as left screenshot shown. Of course, you can insert them one by one, but are there any quick ways to insert the page breaks at once based on the changed values of one column?
The following VBA code can help you to insert page breaks below based on once column data changes, please do as follows:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Insert page breaks when the value changes:
Sub insertpagebreaks() 'updateby Extendoffice Dim I As Long, J As Long J = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row For I = J To 2 Step -1 If Range("A" & I).Value <> Range("A" & I - 1).Value Then ActiveSheet.HPageBreaks.Add Before:=Range("A" & I) End If Next I End Sub
3. Then press F5 key to run this code, all page breaks have been inserted into the sheet when data changes in column A. See screenshot:
If you have Kutools for Excel, with its Distinguish differences feature, you can quickly insert page breaks, blank rows, bottom border lines or background color based on the value changes.
After installing Kutools for Excel, please do as this:
1. Click Kutools > Format > Distinguish differences, see screenshot:
2. In the popped out Distinguish differences by key column dialog box, do the following operations:
3. Then click Ok button, the page breaks have been inserted into the range based on the value changes see screenshot: