View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
darlove darlove is offline
external usenet poster
 
Posts: 14
Default Deleting HPageBreaks returns...

Hi again.

Well... the news is not as good as you'd probably like it to be. I
slightly made your sub over to read like this:

Sub GetRidOfThem()
Dim rngAll As Excel.Range
Dim rngRow As Excel.Range

Set rngAll = Range("header").CurrentRegion.Rows
For Each rngRow In rngAll
If rngRow.EntireRow.PageBreak < xlNone Then
rngRow.EntireRow.PageBreak = xlNone
End If
Next
End Sub

and though there is no error this time - which is maybe even more
intriguing - it does not remove any page breaks at all. If this sub
worked as it's supposed to, this would be the end to my questions. Can
you see why it does not do the job it should? (Your version works fine
but removes automatic page breaks only and I want to dump them all from
the Range("header").CurrentRegion area.)

By the way, why do you set the object variables at the end of your sub
to Nothing? Isn't it that when the sub ends, then the variables go out
of scope and the objects that the variables point to are destroyed
automatically? Actually, in this context the objects cannot be
destroyed whatsoever because they HAVE TO exist for the sake of Excel's
very nature... Excel cannot destroy any range that exists on a sheet.
Am I right or not? Any reply will, of course, be much appreciated.

Regards
Darlove (PL)