Vous êtes sur la page 1sur 6

https://id.pinterest.

com/pin/374432156497138403/

Sub AddBreaks()
StartRow = 2
FinalRow = Range("A65536").End(xlUp).Row
LastVal = Cells(StartRow, 1).Value

For i = StartRow To FinalRow


ThisVal = Cells(i, 1).Value
If Not ThisVal = LastVal Then
ActiveSheet.HPageBreaks.Add _
before:=Cells(i, 1)
End If
LastVal = ThisVal
Next i
End Sub

Re: Insert page break "after" condition met?

Try this...
Code:

Sub PageBreak()

Dim c As Range
Dim FirstAddress As String

Set c = Columns("B").Find(What:="TOTAL", LookIn:=xlValues, LookAt:=xlWhole,


MatchCase:=True)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(1)
Set c = Columns("B").FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If

End Sub
http://kickasstorrents.video/kutools-for-excel-7-5-5-x86-x64-crack-t10157188.html

Re: Insert page break "after" condition met?

Sub PageBreak()

Dim c As Range
Dim FirstAddress As String

Set c = Columns("B").Find(What:="TOTAL", LookIn:=xlValues, LookAt:=xlWhole,


MatchCase:=True)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(1)
Set c = Columns("B").FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If

End Sub

You can try this instead:

Sub testing()
Dim pattern As String
pattern = "Total"
RowCount = ActiveSheet.UsedRange.Rows.Count
Dim i As Integer

For i = 1 To RowCount
Dim j As Integer
For j = 1 To 1
If Cells(i, j) = pattern Then
Cells(i, j).EntireRow.Delete
End If
Next j
Next i
End Sub

This may have more lines of code,but this will be helpful to explain your concept.
To insert it do the following in excel:

press Alt+F11
Rightclick Sheet1
->Insert->Module and paste this code.

0
down vote

If you select the entire range, the following macro should delete every row that
has a cell that contains "total", regardless of case.

Sub Test()
Dim cell As Range

For Each cell In Selection


If InStr(1, cell, "total", vbTextCompare) > 0 Then
cell.EntireRow.Delete
End If
Next
End Sub

To insert it, do the following in Excel:

Press Alt+F11
Click Insert>Module
Copy and paste the above macro into the new module.
Option Explicit

Sub PageBreaks()

Dim c As Range
Dim FirstAddress As String
Dim Search As String
Dim Prompt As String
Dim Title As String

Prompt = "What do you want to search for?"


Title = "Search Term Input"
Search = InputBox(Prompt, Title)
If Search = "" Then
Exit Sub
End If
With ActiveSheet.UsedRange
Set c = .Find(What:=Search, LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=True)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With

End Sub

How to use:

Open Excel.
Alt + F11 to open the VBE.
Insert | Module.
Paste the code there.
Close the VBE (Alt + Q or press the X in the top right corner).

Test the code:

Tools | Macro | Macros...


Select PageBreaks and press Run.
Sample File:

PageBreaks.zip 8.16KB

C:\Documents and Settings\sapph\Application Data\Microsoft\Word\STARTUP

Maaool ha olak rooh,


Is it possible that I would tell you to leave,
Mengheir makoon magrooh?
If it wasn't because I was hurt?
Wala baqi ala haga.
Thinking there was nothing left of us.
La danta mosh arif.
No, you don't know.

Maaool tesadaa abee,


Is it possible you would think I've given up,
Mengheir matooh wala dee?
Without getting lost and broken?
Wala akhafsh men haga.
Without fearing anything.
La danta mosh aarif.
No, you don't know.

Chorus 1:
Baadak hahis be meen?
After you who can I love?
Maoola hob seneen,
Is it possible that our love of years,
Yekhlas fe dameit ein?
Can finish with the drop of a tear?
Ya habibi la!
No, my darling, no!

Chorus 2:
La, la, la, la.
No, no, no, no.
La, we alf la.
No, and a thousand nos.
Dana albi baad gheyabak tah.
My heart, after you left, became lost.
Law belkalam,
If with words,
Nensa el alam.
We could forget the pain.
Da makansh al wala asheq aah.
Then never would one lover have cried in pain.

Maaool habibi misheet?


Is it possible, my darling, that you have left.
Maaool fakerni niseet?
Is it possible you thought I forgot?
Law albi aal haga,
If my heart said anything,
Men garho alhalak.
He said it because he was hurt.

Dana lama kont baool,


When I use to say something,
Baasood kalami yetool.
I had meant to get a response from you.
Yemken teool haga,
Maybe you would say something,
Asmaha asfalak.
I could have heard it and forgiven you.