Consulting

Results 1 to 3 of 3

Thread: Solved: Calculate Number of pages

  1. #1
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location

    Solved: Calculate Number of pages

    My current code feels a little awkward.... I need to put three funds per page into a report. Is there a simpler way to do this?

        'calculate pages
        If intFunds < 4 Then
       'One page
       intPages = 1
       Else
            '   Multiple Pages
       If (intFunds Mod 3) = 0 Then
          intPages = Int(intFunds / 3)
          Else
          intPages = Int(intFunds / 3) + 1
       End If
        End If
    Last edited by Aussiebear; 03-27-2023 at 08:56 PM. Reason: Adjusted the code tags

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    try just one line:
     intpages = Application.Ceiling(intfunds / 3, 1)
    Last edited by Aussiebear; 03-27-2023 at 08:57 PM. Reason: Adjusted the code tags
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location
    Quote Originally Posted by p45cal
    try just one line:
    Ahah! I should have thought to check the Worksheet Functions.

    Thank you very much, that is perfect.

Posting Permissions

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