Consulting

Results 1 to 3 of 3

Thread: Subtotal at each PageBreak

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Apr 2019
    Posts
    14
    Location

    Post Subtotal at each PageBreak

    Hello guys,

    I really need your help with an VBA project I have to complete. The main goal is to convert an invoice from excel to word with the help of VBA.

    My invoice starts at row 20 and has a widht of 8 columns, I want the subtotal of the amount in column 8 (column H) at each pagebreak. If it's possible it would be perfect when the subtotal is transfered to the next page.

    When I run my code there are 22 rows with articles and prices (maybe that helps).

    I hope you can help me with this issue (it bothers me for so long) and if you need further information to help, I will provide it to you.

    Thank you

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi vloneboy!
    Welcome to vbax forum.
    It would be helpful if there was an example, The following code is for reference only.
    Sub Test()
      Dim i&, r&, st&, en&
      st = 20
      With Sheets(1)
        For i = 1 To .HPageBreaks.Count
          r = .HPageBreaks(i).Location.Row - 1
          en = r - 1
          .Rows(r).Insert
          .Cells(r, 8) = "=sum(H" & st & ":H" & en & ")"
          st = r + 1
        Next i
      End With
    End Sub

  3. #3
    VBAX Regular
    Joined
    Jan 2019
    Posts
    6
    Location
    I have a little revised the code from you ???1976.


    I thought, this is what vloneboy wants.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

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