+ Reply to Thread
Results 1 to 2 of 2

formula evaluates differently in VBA and immediate window

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Sofia
    MS-Off Ver
    Excel 2013
    Posts
    10

    formula evaluates differently in VBA and immediate window

    Hi,

    I have a variable for exchange rate (Dim rate1 as Long). It does not evaluate correctly. rate1 evaluates as 1 in the VBA code, and it evaluates as 1.2701 in the immediate window using the same formula. It looks like it takes the integer value even though i declared it to be a long variable. If I change the rate to 2.2701 it evaluates as 2 in the code, and as 2.2701 in the immediate window.

    any idea why?

    thanks!


    rate = Application.Index(Sheets("Exchange Rates").Range("A1:C1000"), _
    Application.Match(Mid(trffromacc, 5, 3), Sheets("Exchange Rates").Range("A:A"), 0), 2)

    rate1 = Application.Index(Sheets("Exchange Rates").Range("A1:C1000"), _
    Application.Match(Mid(trftoacc, 5, 3), Sheets("Exchange Rates").Range("A:A"), 0), 2)

    https://onedrive.live.com/redir?resi...nt=photo%2cpng
    Last edited by goldfrapp01; 12-09-2014 at 07:52 AM.

  2. #2
    Registered User
    Join Date
    01-25-2013
    Location
    Sofia
    MS-Off Ver
    Excel 2013
    Posts
    10

    Re: formula evaluates differently in VBA and immediate window

    Yes, it must be declared as Double.

+ 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. Macro behaves differently if lunch from a button vs. VBA window
    By dorindanci in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-21-2014, 02:37 PM
  2. IF formula evaluates to wrong value
    By igardos44 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-30-2014, 10:23 AM
  3. lookup formula that evaluates two criteria
    By waternut in forum Excel General
    Replies: 3
    Last Post: 09-02-2011, 08:57 AM
  4. SUM formula evaluates to zero. Why?
    By paulr in forum Excel General
    Replies: 2
    Last Post: 02-12-2009, 04:42 PM
  5. Formula evaluates to #VALUE
    By glen.e.mettler@lmco.com in forum Excel General
    Replies: 4
    Last Post: 03-28-2006, 08:45 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