roundup and rounddown
roundup and rounddown
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: roundup and rounddown

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    429
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I am simply trying to round numbers up or down.

    Example if the numbers are: 49.6, 38.7 they need to be 49 and 38

    For the round up it would be the opposite 50 and 39.

    I can't get the roundup and rounddown function to work in the macro, i don't
    know why? the round function seems to work but it doesn't do it correctly.

    this is what I have so far...

    Sub RoundUp()

    SRow = ActiveCell.Row
    SCol = ActiveCell.Column
    RH = SCol - 4
    FinalRow = Range("A65536").End(xlUp).Row

    For i = SRow + 1 To FinalRow
    If Cells(i, RH).Value <> 0 Then
    Cells(i, SCol).Value = Round(Cells(i, RH), 0)
    End If
    Next i

    End Sub

    Thanks,

    Lino


  2. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try using Application.WorksheetFunction.RoundUp
    and
    Application.WorksheetFunction.RoundDown

    I hope this helps.
    Kind regards, Al.

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    429
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Al,

    where would I integrate in my code what you have advised?

    thanks,

    lino

  4. #4
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    If the round function is not working correctly then replace the round function with application.worksheetfunction.roundup(number,num_digits) or rounddown depending on what you want to do.

    I hope this helps.
    Kind regards, Al.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com