Got any Excel/VBA Questions? Free Excel Help
DeZaStR needed to write a macro that checks a column of numbers, and each time the number changes, insert a page break. For example, you have a column with all 10's in each row, but on row 25 it then becomes 15's...at that point he wanted a page break.
Richie(UK) provided the following code
Dim rngMyRange As Range, rngCell As Range
Set rngMyRange = .Range(.Range("B1"), .Range("B65536").End(xlUp))
'the range to work with
For Each rngCell In rngMyRange
'loop through the range
If rngCell.Value <> rngCell.Offset(1, 0).Value Then
.HPageBreaks.Add Before:=rngCell.Offset(1, 0)
Epidemic provided an alternative loop
col = 2 ' what ever column you want to measure.
LastRw = ActiveSheet.UsedRange.Rows.Count
For x = 2 To LastRw
If Cells(x, col) <> Cells(x - 1, col) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(x, col)
DeZaStR noted that both coded solutions worked “great” – Thanks guys.
|Excel Date & Time Calculations|
|Return The Weekday of Date in Excel|
|Debug VBA Code|
|Debug, Evaluate/Audit & Fix Excel Formula Errors|
|Decreasing Validation Lists|
|Excel Formulas/Formulae, Tips, Tricks and Feature Examples|
Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft.
read the full review here .The active component that helps to cope with erectile dysfunction is sildenafil. The drug increases blood flow to the penis, but men need sexual stimulation. It is usually drunk in a dosage of 50 mg, once. It must be taken 1 hour before the intended sexual act. The maximum allowable dose is 100 mg per day, the minimum is 25 mg.