+ Reply to Thread
Results 1 to 2 of 2

Problems using If-statement

  1. #1
    Registered User
    Join Date
    05-01-2015
    Location
    Barcelona
    MS-Off Ver
    Excel 2013
    Posts
    4

    Problems using If-statement

    Hello,

    I use three columns. The first column is some ID-number for a firm (e.g. A1=1, A2=2, A3=3, etc.). The second column contains a characteristic of that particular firm (for example, firm 1 produces ten cookies per month, then B1=10, firm 2 produces twenty cookies per month, B2=20, etc.). The problem is that there are multiple observations for one firm. How could we use If-statements to automatically assign the number of cookies per month to the correct firm?

    What I tried already is something like this: IF(A2=A1;$B$1;$B$2). This works for the first firm, but for the second firm, it only works for the first observation and then I have to adjust the if-statement manually, which takes too much time.

  2. #2
    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,946

    Re: Problems using If-statement

    HI, welcome to the forum

    I suggest that you make a list/table of all firms and their output. Then use a vlookup() in your main table to return the value you want. Something like this...
    A
    B
    C
    D
    E
    1
    Firm Cookies Firm Cookies
    2
    aa
    10
    aa
    10
    3
    bb
    20
    bb
    20
    4
    aa
    10
    cc
    30
    5
    bb
    20
    6
    cc
    30

    B2=if(A2="","",VLOOKUP(A2,$D$2:$E$4,2,0))
    copied down
    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

+ 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. [SOLVED] If then statement problems
    By LostGuy80 in forum Excel General
    Replies: 15
    Last Post: 11-18-2014, 12:39 AM
  2. [SOLVED] Problems with an IF statement
    By icarrington in forum Excel General
    Replies: 2
    Last Post: 08-23-2012, 07:56 AM
  3. IF statement problems
    By Toddneyx in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-14-2010, 05:11 AM
  4. If Then Statement Problems
    By Snurry in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-18-2009, 05:20 AM
  5. if statement problems
    By nighttrain112 in forum Excel General
    Replies: 2
    Last Post: 01-21-2008, 08:32 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