+ Reply to Thread
Results 1 to 3 of 3

VBA If Then function

  1. #1
    Registered User
    Join Date
    05-12-2017
    Location
    Wilmington, NC
    MS-Off Ver
    2010
    Posts
    2

    VBA If Then function

    With Amt, Amt1 and ChkAmt dimensioned as long, I am using the function [If Amt + Amt1 <> ChkAmt Then MsgBox "Check Amounts"] (brackets added for clarity). If Amt +Amt1 equals ChkAmt, nothing should happen, if not a message box should come up saying "Verify Amounts". Amt, Amt1 and ChkAmt are input through a user form. This works fine most of the time. I have formatted the spreadsheet to a two digit number. I also occasionally have an issue with the vlookup function working with certain numbers - namely 206.92. Is this a generic excel problem and is there an answer? I am using Windows 10 and Office 2010.

    I deleted the table and inserted an abridged version of the spreadsheet. Click on the "Input Data" button. In the user form do Not click on the get data button. Input 206.92 in the "Check Amount" box, 130 in the first "Amount" box and 76.92 in the "Amount" box below the first one. Then click on the "Verify" or "Transfer" button. If the two "Amount" entries add to the "Check Amount" entry nothing should happen with the Verify button and the data will be written to the spreadsheet with the Transfer button. If the amounts do not add up to the check amount a message box should appear saying "Verify Amounts". This works well except with the entries given earlier. For instance, a check amount of 206.91 and amounts of 130 and 76.91 work as expected. A lot of the functionality has been deleted for simplicity so don't worry about anything else not functioning properly.

    Thanks, Alan
    Attached Files Attached Files
    Last edited by Alan Lion; 02-24-2018 at 12:44 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA If Then function

    You are probably having some sort of rounding issue. It is impossible to diagnose from the information you have provided.

    What are the formulas in each column?

    It will be much easier to understand your problem if you provide your file. This allows us to see and experiment with your data, layout, formulas, code, and possibly attach a file with a completed solution. If you are looking for formulas to produce a desired result, it helps if you create a mock-up of what you want the result to look like. Otherwise we would have to build something from scratch, trying to guess what you want it to look like.

    The paper clip icon does not work for attachments. Instead, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-12-2017
    Location
    Wilmington, NC
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA If Then function

    Thanks, I tried to attach a file but couldn't. I'll edit the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 08-14-2017, 06:26 AM
  2. [SOLVED] Usage of standard functions into custom function (or user defined function)
    By tusharb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2016, 12:43 AM
  3. Calling function inside function. (aka nested function)
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 05:58 AM
  4. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  5. Replies: 2
    Last Post: 01-15-2014, 11:40 PM
  6. Replies: 1
    Last Post: 03-21-2012, 11:22 AM
  7. Replies: 2
    Last Post: 03-20-2009, 01:29 PM

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