PPT Embedded XL Sheet Rounding down instead of Up??

L

lance-news

Hello,

If one rounds 6.5 should be Round down to 6?
I thought one usually rounded up so that rounding
6.5 would round to 7??

Given my code below though, if I have two cells, one
at 6.5 and one at 7.1 then I would expect them to
both round to 7. Instead, 7.1 rounds to 7 and 6.5
rounds to 6?? I am using Office XP.

Lance




Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet

Dim SlideObject As Slide
Dim ShapeObject As Shape

Dim maxval As Variant
ActivePresentation.Slides(4).Select
Set SlideObject = ActivePresentation.Slides(4)


For Each ShapeObject In SlideObject.Shapes
If ShapeObject.Type = msoEmbeddedOLEObject Then
If Mid$(ShapeObject.OLEFormat.ProgID, 1, 11) =
"Excel.Sheet" Then
Set oXLBook = ShapeObject.OLEFormat.Object

oXLBook.Application.DisplayAlerts = False

'REPLACE NON-NUMERIC DATA WITH NUMBERIC DATA BECAUSE .MAX WON'T WORK
WITH NON-NUMERIC DATA
oXLBook.Application.DisplayAlerts = False
oXLBook.Worksheets("Sheet1").Cells.Replace What:="<1%",
Replacement:=".0005", LookAt:=xlPart, MatchCase:=False
oXLBook.Worksheets("Sheet1").Cells.Replace What:="- -",
Replacement:=".0001", LookAt:=xlPart, MatchCase:=False

'Code for Line 3
maxanswer03 =
Round(oXLBook.Application.WorksheetFunction.Max(oXLBook.Worksheets("Sheet1").Range("B3:O3")))
If (Round(oXLBook.Worksheets("Sheet1").Range("B3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 225, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("D3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 286, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("F3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 345, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("H3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 405, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("J3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 465, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("L3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 525, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("N3").Value) = maxanswer03)
Then SlideObject.Shapes.AddShape(9, 585, 180, 35, 35).Select
MINANSWER03 =
Round(oXLBook.Application.WorksheetFunction.Min(oXLBook.Worksheets("Sheet1").Range("B3:O3")))
If (Round(oXLBook.Worksheets("Sheet1").Range("B3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 225, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("D3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 286, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("F3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 345, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("H3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 405, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("J3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 465, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("L3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 525, 180, 35, 35).Select
If (Round(oXLBook.Worksheets("Sheet1").Range("N3").Value) = MINANSWER03)
Then SlideObject.Shapes.AddShape(1, 585, 180, 35, 35).Select
 
S

Steve Rindsberg

If one rounds 6.5 should be Round down to 6?
I thought one usually rounded up so that rounding
6.5 would round to 7??

I think you may have taken a wrong turn a few doors back up the hallway.
You've wandered into a den of (gasp) PowerPoint users.

I'm not sure who made the rules and why, but 6.5 seems to round to 6, but 6.000000001
rounds to 7; you could try adding .000000001 to your value before rounding it if you
want to force X.5 to round to X+1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top