+ Reply to Thread
Results 1 to 5 of 5

Using IF function and a VLOOKUP in VBA - Basic uses

  1. #1
    Registered User
    Join Date
    04-15-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Using IF function and a VLOOKUP in VBA - Basic uses

    Hello all,

    I am not a great VB programmer (my background is in C), and I cnanot get my VB code to look at a cell and return false if it has no contents and true otherwise.

    Also I want it to check the cell on a different tab, what is the most efficient way of doing this without ".select"ing everything?

    Cheers

    p.s. Can you use the VLOOKUP excel funtion within your VBA code?
    Last edited by ste_mulv; 12-21-2009 at 05:41 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Help on a simple if Function

    Hello ste_mulv,

    Difficult to answer when your question is ambiguous. Is this "If" statement a worksheet function or a VBA statement? What does VLookup have to do with the "If" statement? You should your show code for clarification.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help on a simple if Function

    Something like:
    Please Login or Register  to view this content.

    Yes, you can also use VLOOKUP in VBA.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 12-17-2009 at 01:54 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    11-20-2009
    Location
    Raymond,WA
    MS-Off Ver
    Excel 2002
    Posts
    40

    Re: Help on a simple if Function

    Hope this will help you do what you need to.

    Please Login or Register  to view this content.
    One can use the vlookup function in VB code.

    I showed 2 different methods to check the cell contents. Don't know which would be most matches what you need.

    You can reference cells without selecting them just by giving their address.
    I'm new to VB, so my answers may not be semantically correct.
    Last edited by TimK; 12-18-2009 at 01:04 AM. Reason: spelling

  5. #5
    Registered User
    Join Date
    04-15-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Using IF function and a VLOOKUP in VBA - Basic uses

    Cheers for the help there guys...

    I got the vlookup up and running straight away and I started to use the IF statement, and it worked great, but I ended up changing to the Select Case statement.

    here is an extract from my code.

    Please Login or Register  to view this content.
    the select case allows me to added in additional values at a later date.

    Thanks again...

    Steve

+ 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