+ Reply to Thread
Results 1 to 2 of 2

VBA IF statement equaling numbers (decimal position rounding problem)

  1. #1
    Registered User
    Join Date
    08-05-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    36

    VBA IF statement equaling numbers (decimal position rounding problem)

    Hello,

    I have two different tabs. I have a master tab with every single value I am trying to look for (using vlookup) and another one which I'm basing my vlookup off of.

    The values in the master sheet have values that could go down to the tenth thousands digit (ie 43.1246.) The other sheet only has it down to the hundredth (43.13.) I have an if statement that executes a step if two values in different cells are equal.

    However, the problem I'm running into is that the vlookup doesn't know to round up the value to the nearest hundredth so that when I run the macro to find equal values, it comes up as a match. Instead a lot of these numbers that are supposed to be rounded up come up as miss matches and the step is completely skipped, leaving me with a lot of missing info.

    Is there a way to put this in the program to match numbers down to the hundredth value so the match can occur?

    Thanks!
    Last edited by farzyness; 09-10-2010 at 02:32 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: VBA IF statement equaling numbers (decimal position rounding problem)

    It can certainly be done. The function equivalent to lookup a number rounded up to the nearest hundredth in a VLOOKUP would look like:

    =VLOOKUP(ROUNDUP(F1,2),$A$1:$B$4,2,0)

    Convert that to VBA and you're set. If you don't know how, provide your current code and it can be incorporated here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1