Does this work for you?
Sub InsertPageBreaksByDateAndRowCount()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim rowCount As Long
Dim currentDate As Date
' Set the worksheet you are working with
Set ws = ThisWorkbook.Sheets("YourSheetName") ' Change "YourSheetName" to the actual sheet name
' Find the last row in Column A with data
lastRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
' Initialize variables rowCount = 0
currentDate = ws.Cells(1, "A").Value
' Assume the first date is in A1
' Loop through the rows
For i = 1 To lastRow
' Check for date change
If ws.Cells(i, "A").Value <> currentDate Then
' Insert a page break before the current row if it's not the first row
If i > 1 Then
ws.Rows(i).PageBreak = xlPageBreakManual
End If
currentDate = ws.Cells(i, "A").Value
rowCount = 1
' Reset row count for the new date
Else
rowCount = rowCount + 1
End If
' Check if the row count for the current page exceeds 25
If rowCount > 25 Then
' Insert a page break before the current row
ws.Rows(i).PageBreak = xlPageBreakManual
rowCount = 1
' Reset row count for the new page
End If
Next i
MsgBox "Page breaks inserted based on date changes and a maximum of 25 rows per page.", vbInformation
End Sub