Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default More HpageBreaks Strangeness

I am attempting to write a procedure that moves the Hpagebreaks on a worksheet so that all of the data from one section
is on the same page. I have written a procedure that does just that, but it does not work when I call it from another
procedure. It always fails with a 1004 error. If I call the procedure manually from the immediate window it runs perfect
every time.

Here is the code:

Public Sub PageBreaks(strWsName As String)

Dim phHoriz As HPageBreak
Dim rngPageBreak As Range
Dim nochanges As Boolean
Dim shtTimeCard As Worksheet

Set shtTimeCard = Sheets(strWsName)

nochanges = False

Do Until nochanges
For Each phHoriz In shtTimeCard.HPageBreaks
nochanges = True
Set rngPageBreak = phHoriz.Location
If rngPageBreak.Value < "" Then
nochanges = False
Do Until rngPageBreak.Value = ""
Set rngPageBreak = shtTimeCard.Cells(rngPageBreak.Row - 1, 1)
Loop
Set phHoriz.Location = rngPageBreak
End If
Next phHoriz
Loop

End Sub

The error always occurs at the line "Set phHoriz.Location = rngPageBreak". I have tried various ways around it, and am
perplexed as to the behavior I am seeing. I mean, if there is an error, why does it alway work when run from the
immediate window, but never when called from any other procedure? If anyone has any ideas, I would really appreciate the
feedback.

Thanks,
Bill
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formatting strangeness Allenx Excel Worksheet Functions 0 March 14th 07 02:58 PM
Conditional formatting strangeness duncan79 Excel Discussion (Misc queries) 5 May 18th 06 05:02 AM
Conditional formatting strangeness christopherp Excel Discussion (Misc queries) 13 March 6th 06 12:51 PM
Is there no one who uses PageBreaks? HPageBreaks? GeorGeorGe Excel Worksheet Functions 0 February 11th 05 05:53 PM
HPageBreaks.Add GeorGeorGe Excel Worksheet Functions 0 February 9th 05 09:31 PM


All times are GMT +1. The time now is 04:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"