Results 1 to 6 of 6

Thread: VBA code working on one file, giving error on another

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2023
    Posts
    2
    Location

    VBA code working on one file, giving error on another

    Hi, I've two Excel with Macro files. I copied a couple of pages from one to another. I had two macros, one for exporting to Pdf which is working fine also in the new file, and another one that would hide/show a section of a document.<br>This second one keeps giving error, while in the older file it's still working fine.<br>I don't understand why it's giving error. Can somebody help?

    Sub ShowHideHP2()
    ' RemovePbreak Macro
    Sheets("QUOTE").Select
    Rows("318:536").Select
        If Selection.EntireRow.Hidden = True Then
       Selection.EntireRow.Hidden = False
       'Add Row Page Break
       Worksheets("QUOTE").Rows(318).PageBreak = xlPageBreakManual
       Worksheets("QUOTE").Rows(405).PageBreak = xlPageBreakManual
       Worksheets("QUOTE").Rows(471).PageBreak = xlPageBreakManual
       Else
       Selection.EntireRow.Hidden = True  (ON THIS LINE IS GIVING ERROR)
       'Clear Row Page
       Worksheets("QUOTE").Rows(318).PageBreak = xlPageBreakNone
       Worksheets("QUOTE").Rows(405).PageBreak = xlPageBreakNone
       Worksheets("QUOTE").Rows(471).PageBreak = xlPageBreakNone
    End If
    Sheets("Main calcs").Select
    End Sub
    Last edited by Aussiebear; 03-08-2023 at 11:35 AM. Reason: Added code tags to supplied code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •