+ Reply to Thread
Results 1 to 11 of 11

VBA to replace lengthy Nested IF statements

  1. #1
    Registered User
    Join Date
    08-03-2006
    Posts
    12

    VBA to replace lengthy Nested IF statements

    New project...

    Can someone please point me in the right direction. I am working to simplify an existing spreadsheet that has multiple lengthy nested IF statements. The need to do so is based on the restriction of 64. I've tried VLOOKUP, etc and have found nothing that has worked well as of yet. The following is an example of what I am trying to do...

    Column A - User enters an inventory code (001-500)
    Column O - This is the list of inventory codes (001-500)
    Column P - This is the item description associated with the inventory code in column O

    Goal - Once user enters inventory code (001-500) in column A, I need column B to automatically populate with the description in column P (associated with it's code in column O).

    Hope that all makes sense. I tried a search and could not find exactly what I was looking for on the web.

    Many Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA to replace lengthy Nested IF statements

    VLOOKUP should work, how did you try it and how did it not work?

    Are the values in column 0 numeric or numbers stored as text?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-03-2006
    Posts
    12

    Re: VBA to replace lengthy Nested IF statements

    The VLOOKUP was limited to 64, I have approximately 500 inventory items / codes. Unfortunately the inventory codes are specific and cannot be changed for this purpose. All codes are both letters and numbers. Example - CDM.02

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA to replace lengthy Nested IF statements

    Agree that it sounds like vlookup should work.

    Can you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA to replace lengthy Nested IF statements

    Limited to 64 what?

    I would have though a simple VLOOKUP like this would be all you needed.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-03-2006
    Posts
    12

    Re: VBA to replace lengthy Nested IF statements

    The portion I have been tasked with working is attached.
    Attached Files Attached Files

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA to replace lengthy Nested IF statements

    Put this in D8 and copy down.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-03-2006
    Posts
    12

    Re: VBA to replace lengthy Nested IF statements

    Awesome, Thank you sir. Any way to not have the #N/A in the cells until you enter a value in the B column? Not a big deal, just curious.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA to replace lengthy Nested IF statements

    maybe this...
    =iferror(VLOOKUP(B8, $O$1:$Q$1000,3, 0),"")

  10. #10
    Registered User
    Join Date
    08-03-2006
    Posts
    12

    Re: VBA to replace lengthy Nested IF statements

    Again, perfect. Thank You!

  11. #11
    Registered User
    Join Date
    08-03-2006
    Posts
    12

    Re: VBA to replace lengthy Nested IF statements

    I'm not sure if it is my job to mark this as solved or not. I was unable to determine just how to do that if so. Thanks to the folks that assisted, I may be back as this project progresses. Thanks again!

+ 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. Making lengthy AND statements succinct
    By Gingermuppet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2013, 10:39 AM
  2. questions with if statements and nested if statements
    By Pat Excel in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-03-2013, 01:41 PM
  3. function to replace nested if statements with linked tables
    By javon27 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-20-2010, 04:30 PM
  4. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  5. Lengthy If_Then Statements in FormulaArray
    By inwalkedbud in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2007, 03:41 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