+ Reply to Thread
Results 1 to 10 of 10

Assign a value to a cell based on a portion of the content of another cell

  1. #1
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Assign a value to a cell based on a portion of the content of another cell

    Hi all,

    I'm trying to create a budget and I'd like to create a formula that will automatically categorize my transactions. I already have a working formula started, but I'll reach the maximum character allotment before including all of the categories. Here's a shortened example. The transportation category alone would need to reference 50+ cells from sheet1 instead of the two shown in the example.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    While a lot of my transactions will be repetitive, I'll obviously shop at new places every year. Having a separate sheet of keywords will give me the flexibility to include these new businesses in the search without having to change the formula. I'll have placeholder keywords of randomly typed text that will never return a positive result when searching the transaction list. Then when I shop at a new place, I can substitute that text with the relevant text from the transaction description. Is there another way that I can go about this that will use less characters? I can probably fit about 70% of the current formula before I run out of characters.

    Any help would be greatly appreciated. Thanks in advance!

    Brian

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign a value to a cell based on a portion of the content of another cell

    Sounds like you need to build a table and use a lookup function.

    See if this helps:

    http://contextures.com/xlFunctions02.html
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Assign a value to a cell based on a portion of the content of another cell

    I'm not sure how that would work. How would I create a table with my example? In the example you provided everything is static. Everything has one product code and price. But for my example, every category has multiple key words, and every key word will reference multiple transactions.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign a value to a cell based on a portion of the content of another cell

    Can you post a SMALL sample file and show us what result you expect?

    A SMALL file will have about 20 rows worth of data.

  5. #5
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Assign a value to a cell based on a portion of the content of another cell

    Ok, here's the bare bones of what I'm doing here. My transactions download in 5 columns, A,B,C,D, and E. What I would like to do is categorize and sum these transactions by category. I would like a formula that automatically assigns a category if I've shopped there before. As you can see in columns F and G, I do have a working formula, it's just too long once I get all of my categories and keywords listed. If only there was a way I wouldn't have to list "ISNUMBER" so many times. I was hoping there would be a way to only use "ISNUMBER" once per category instead of once per keyword. Basically tell it to search all these keywords, and if one of them is a number, then spit out the corresponding category. Hope that made sense...

    I may have a band-aid solution though. I can fit as many categories as I can into a formula, and when it comes up "False", I can have it return "Continue". Then in the next column I can do =IF(F2="Continue",yada yada yada... Do you see an easier solution to sum by category, or should I just run with my band-aid fix? Thanks!
    Attached Files Attached Files

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign a value to a cell based on a portion of the content of another cell

    If you can create a table in this format...

    Data Range
    A
    B
    C
    1
    Category
    Subcategory
    Business
    2
    Food
    Groceries
    Woodman's Food
    3
    Food
    Groceries
    725 SOUTH GAMMON
    4
    Food
    Groceries
    3010 CAHILL MAIN
    5
    Food
    Fast Food
    Popeyes
    6
    Food
    Fast Food
    Arbys
    7
    Food
    Fast Food
    McDonald's
    8
    Food
    Restaurants
    Great Dane
    9
    Food
    Restaurants
    OLIVE GARD00


    ...Then we can come up with a significantly shorter formula.

  7. #7
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Assign a value to a cell based on a portion of the content of another cell

    Thanks, but unfortunately I'm still a bit lost. I've only used lookup formulas in limited fashion before and they were always for exact matches. What value would I be looking up, Transactions!C2? Or the range of cells in column C from your table?

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign a value to a cell based on a portion of the content of another cell

    This is the entry in D2 on the Transactions sheet:

    Download from usbank.com. 010111PSE4TERM725 SOUTH GAMMONMADISON WI00

    We would search that entry for each of the keyword/phrases in the Business column.

    We would get a match on the phrase "725 SOUTH GAMMON" and can use that to return either the corresponding category or subcategory.

    Here's a simplified example:

    Data Range
    A
    B
    C
    1
    2
    POS 123 xxx WalMart 21B
    WalMart
    Sears
    3
    Amazon
    4
    Macy's
    5
    WalMart
    6
    Penney's
    7
    Hackers Helper


    This formula entered in B2:

    =IFERROR(LOOKUP(1E100,SEARCH(C2:C7,A2),C2:C7),"")

  9. #9
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Assign a value to a cell based on a portion of the content of another cell

    Awesome, that's perfect!! I kept the table on a separate sheet from the transactions and used this formula for categories:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And this one for subcategories:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This also gives me the benefit of being able to use a ton of placeholder cells so I should never have to edit my formula no matter how many different businesses I have transactions with. Would you mind explaining what the 1E100 is though?

  10. #10
    Registered User
    Join Date
    09-30-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Assign a value to a cell based on a portion of the content of another cell

    I was able to find what the 1E100 is with a little research, but I'm still having trouble understanding how this formula actually works. I get that the 1E100 is a larger number than can be returned by any of the searches because of character limits for each cell, but I don't see why it's returning a value from the table. Out of curiosity I changed it to a low number to see what would happen and I noticed that if the lookup# is greater than or equal to the starting position of any positive result, it will return the table value. If it's lower than the starting position, then it returns the error value, or in this case a blank cell. Why is that?

+ 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. VBA lock a portion of the worksheet based on cell value
    By hinklejt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2014, 04:23 PM
  2. copying cell content into a specific workbook based on the content in that cell
    By krishna reddy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2012, 03:52 AM
  3. [SOLVED] assign cell content to variable
    By echomom in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2011, 01:47 PM
  4. [SOLVED] Assign Cell Content As File Name
    By paul.sternhagen@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2005, 02:05 PM
  5. [SOLVED] assign cell content as file name
    By paul.sternhagen@gmail.com in forum Excel General
    Replies: 1
    Last Post: 10-18-2005, 01:05 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