+ Reply to Thread
Results 1 to 7 of 7

vba WorksheetFunction Lookup(2,1/Countif(........))

  1. #1
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    vba WorksheetFunction Lookup(2,1/Countif(........))

    Hello everyone,

    Please take a look at this formula and see what's wrong:

    x=Application.WorksheetFunction.LOOKUP(2,1/(WorksheetFunction.COUNTIF(Sheet8.Range("B3:B351"),"">"" & Sheet8.Range("B3:B351")=0),Sheet8.Range("B3:B351"))


    Thank you.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: vba WorksheetFunction Lookup(2,1/Countif(........))

    It is a lot better to post a sample work sheet.

    however.

    Lookup format is = LOOKUP( value, lookup_range, [result_range] )

    So you are looking for the value 2

    Your Range to look in is: 1/(WorksheetFunction.COUNTIF(Sheet8.Range("B3:B351"). ie 1 ( what is the 1 doing? = Error ) / Error = Error

    CountIf format =COUNTIF (range, criteria). You have a range but no criteria


    There is more but that is enough to be getting on with.




    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: vba WorksheetFunction Lookup(2,1/Countif(........))

    mehmetcik,
    Thank you for your reply. I uploaded a sample workbook which contains the formula that works but when try to build it in a VB module, it fails. it says "Type Mismatched". Could you take a look at the formula in module1.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: vba WorksheetFunction Lookup(2,1/Countif(........))

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: vba WorksheetFunction Lookup(2,1/Countif(........))

    Thank you so much it works!

    Question: 1)

    How come when I do this, it doesn't work.
    x = Application.Evaluate("=LOOKUP(2,1/(COUNTIF(rng.address,"">""& rng.address)=0),rng.address)")
    x = Application.Evaluate("=LOOKUP(2,1/(COUNTIF(rng,"">""& rng)=0),rng)")
    both return Error 2029

    Question: 2)

    What's the difference between Evaluate and WorksheetFunction?

    Thanks again.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: vba WorksheetFunction Lookup(2,1/Countif(........))

    I honestly don't know. After you get so far.. It is only trial and error.

    I will see if I can the rng to work


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-03-2020 at 10:13 PM.

  7. #7
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: vba WorksheetFunction Lookup(2,1/Countif(........))

    Thanks, it would great to get the rng to work. I also try making the range into a table and the formula works on table/field name like this x = Application.Evaluate("=LOOKUP(2,1/(COUNTIF(ID[ID],"">""&ID[ID])=0),ID[ID])")
    strange
    Last edited by Xceller; 03-03-2020 at 10:37 PM.

+ 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. WorksheetFunction.CountIf
    By Hellishot141 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-24-2019, 08:48 AM
  2. Application.WorksheetFunction.CountIf in active row
    By Wijnand1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2019, 07:57 AM
  3. [SOLVED] Application.WorksheetFunction.CountIf not working right
    By Cbrehm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2016, 04:49 PM
  4. [SOLVED] Optimizing WorksheetFunction.CountIf
    By daffodil11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2014, 05:06 PM
  5. Application.WorksheetFunction.CountIF
    By krsna83_pp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2011, 08:27 AM
  6. [SOLVED] Error using WorksheetFunction.Countif
    By Kris_Wright_77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2006, 10:45 AM
  7. WorksheetFunction.CountIf
    By hotherps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2005, 11:31 AM

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