ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro doesn't work but recording it does. (https://www.excelbanter.com/excel-discussion-misc-queries/25996-macro-doesnt-work-but-recording-does.html)

Rob

Macro doesn't work but recording it does.
 
Hi all,
I've recorded the following macro and as it's recording the pagebreak is
deleted without a problem.

Private Sub CommandButton1_Click()
Range("F143").Select
ActiveSheet.HPageBreaks(1).Delete
End Sub

If I try to run the macro (making sure all the conditions are the same. ie
the page break is there), I get the error message "Application - Defined or
Object - Defined Error.

Anyone know why this would happen. (I'm using Office 2000.)

Rob




bj

I don't know why it won't work.
Which line gets the error message in debug

"Rob" wrote:

Hi all,
I've recorded the following macro and as it's recording the pagebreak is
deleted without a problem.

Private Sub CommandButton1_Click()
Range("F143").Select
ActiveSheet.HPageBreaks(1).Delete
End Sub

If I try to run the macro (making sure all the conditions are the same. ie
the page break is there), I get the error message "Application - Defined or
Object - Defined Error.

Anyone know why this would happen. (I'm using Office 2000.)

Rob





Rob

Hi bj,

I missed your reply earlier but came across it just now. I don't have the
problem now. It corrected itself somehow. Must have been a hiccup???

Rob

"bj" wrote in message
...
I don't know why it won't work.
Which line gets the error message in debug

"Rob" wrote:

Hi all,
I've recorded the following macro and as it's recording the pagebreak is
deleted without a problem.

Private Sub CommandButton1_Click()
Range("F143").Select
ActiveSheet.HPageBreaks(1).Delete
End Sub

If I try to run the macro (making sure all the conditions are the same.
ie
the page break is there), I get the error message "Application - Defined
or
Object - Defined Error.

Anyone know why this would happen. (I'm using Office 2000.)

Rob








All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com