+ Reply to Thread
Results 1 to 6 of 6

Enter value in cell based on value combination of two other cells

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2007/2010
    Posts
    18

    Enter value in cell based on value combination of two other cells

    Good afternoon everyone. I have a spreadsheet I'm writing a macro for. I've come to road block where I need to have text entered in a cell based on the values in two other cells in the same row.

    In book2.xls - In column D, I need the name of the servicing facility based off the values in columns P and R.

    I've included book3.xls to illustrate the table that I would need to include in the macro. I don't want to have to have an excel table to reference if possible, I'd like it written into the code.


    I appreciate your help. Let me know if you need anymore detail.

    Thanks!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-12-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2007/2010
    Posts
    18

    Re: Enter value in cell based on value combination of two other cells

    One more note, this part of my code will be run on a filtered sheet. The file I included is copied from the original sheet that was filtered. The filter is set to show rows where column D is blank.

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2007/2010
    Posts
    18

    Re: Enter value in cell based on value combination of two other cells

    Any ideas? I've googled the issue but everything out there seems to be task specific, as is mine. I supposed I could just have the macro create that table in book3, reference it, paste values, and delete it. I'd really like to learn how to write it in the code though.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Enter value in cell based on value combination of two other cells

    Do you mean something like this?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-12-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2007/2010
    Posts
    18

    Re: Enter value in cell based on value combination of two other cells

    Thanks for the reply John.

    Unfortunately, it's not that simple. Basically, I need to write code for about 12 nested if statements.

    Something like this

    in cell D2: =if(and(P2="945",or(R2="1ST",R2="2ND")),"0005 Florence Plant",if(and(P2="945",or(R2="CD1",R2="CD2")),"0005 Atlanta Cross Dock",if(and.............

    It ends up with about 12 nested ifs which apparently is too many.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Enter value in cell based on value combination of two other cells

    Well you'd definitely be the one to work out you're logic, but I would suggest putting together a Select Case for Range("D").Value. It would probably make your code clearer than the nested if's.

+ 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