Consulting

Results 1 to 3 of 3

Thread: Really Quick Precision Question

  1. #1

    Really Quick Precision Question

    I have the following

    [VBA]If .Cells(i, j) > 68 Then
    Do some stuff[/VBA]

    The problem is Excel looks at the whole value in Cells(i, j) but I just want it to look up to the tens place.

    So if in the wrksht you see 68.0 in Cells(1, 1) that should return false, but since it is really 68.000001, it returns true.

    How do I remedy this?

  2. #2
    I think this should do it:

    [VBA]If Round(.Cells(i, j), 1) > 68 Then
    Do some stuff [/VBA]

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    CInt(.Cells(i,j)) or CLng(.Cells(i,j)) will give the integer part of the number.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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