+ Reply to Thread
Results 1 to 6 of 6

Using the lookup result as a value

Hybrid View

  1. #1
    Registered User
    Join Date
    10-13-2008
    Location
    South Africa
    Posts
    3

    Using the lookup result as a value

    Hi

    I am having a problem writing a macro that sources one of its values from a cell that contains the following formula =LOOKUP(J9,{0,80,85,90,95},{"0%","40%","60%","80%","100%"}).

    The above formula correctly returns '80%' but when I use this cell as an input for another formula Excel reads it as '0%'.

    Can, and if so how does, one use the resulting value of the lookup function as a fixed value for another function?

    Any help would be much appreciated

    Regards
    Charl
    Last edited by CharlCT; 10-13-2008 at 11:50 AM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    your lookup formula returns strings

    i.e. it returns the 'word' 80%, which Excel thinks of as a word with three letters: 8, 0, %. When you try to do maths with words Excel gives your word a value of 0.

    Try typing these into two cells:
    =n("80%")
    =n(80%)

    (n coerces its argument to a number)

    So, in summary, replace "0%" with 0% etc. in your lookup

    HTH

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065
    A quick test reveals "60%" is interpreted as 0.6, I suspect therefore that your problem lies in the "other formula".
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Registered User
    Join Date
    10-13-2008
    Location
    South Africa
    Posts
    3
    Hi

    Got your reply, CheekyCharlie and rewrote the formula as =LOOKUP(J9,{0,80,85,90,95},{0,25,50,75,100}) which returned 80 and then auto-summed that value to another cell to give me a 'cleaner' value which returned 8000%. I divided by 100 and it now gives me the correct input of 80%. I am using lookup on a lookup result so that may be why the values are quirky (plus the fact that I am new to the lookup function which seems far more likely).

    Thanks to you and Special-K for your speedy assistance.

    Regards
    Charl

  5. #5
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    80% = 0.8

    Divide by 100 within the encapsulated vlookup array.

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Special K.

    I did this test, I also did the tests I outlined. Have you tried coercing the string "80%" and the percentage 80% as I describe in my first post?

    If the results are not what I outline, what version of Excel are you using? This seems very strange... what I describe works perfectly on my machine!

+ 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. Spellnumber
    By Williams in forum Excel - New Users/Basics
    Replies: 13
    Last Post: 02-16-2020, 03:34 AM
  2. number to words
    By vjn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2008, 04:57 AM
  3. Numbers to Text
    By sachinattri in forum Excel General
    Replies: 6
    Last Post: 06-15-2008, 03:07 AM
  4. "Translating" numbers into words
    By Portuga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2008, 11:44 AM
  5. Spell number
    By nowfal in forum Excel General
    Replies: 4
    Last Post: 08-20-2007, 04:21 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