![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 429
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try using Application.WorksheetFunction.RoundUp
and Application.WorksheetFunction.RoundDown I hope this helps. Kind regards, Al. |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 429
|
Al,
where would I integrate in my code what you have advised? thanks, lino |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
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. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|