Results 1 to 3 of 3

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2010

    Excel VBA - Easy Roundup Proc for Integer Numerator and Decimal Denominator

    The following is a nice, eloquent way to selectively round up decimal numbers to the next highest integer --- sort of a ceiling procedure.

    Dim intNum as Integer
    Dim sglDenom as Single
    Dim intQuotient as Integer
    Dim intResult as Integer
    intQuotient = Int(intNum/sglDenom)
    If intNum Mod intQuotient = 0 Then
         intResult = intQuotient
         intResult = intQuotient + 1
    End If
    You could theoretically modify this to do division with two decimal numbers as well. The logic would nearly be the same. I've seen other Roundup methods, some using Case...Select Structures and others using called functions. This could just be dropped into your Sub without calling a procedure, especially if you're looking for a quick and dirty approach.
    Last edited by Hack; Dec 17th, 2010 at 01:33 PM. Reason: Modified Thread Title To Include Office Product Name

Posting Permissions

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


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.