+ Reply to Thread
Results 1 to 7 of 7

How to use a conditional to insert text into a cell based on a number (count) in a cell

  1. #1
    Registered User
    Join Date
    04-15-2015
    Location
    earths
    MS-Off Ver
    2013
    Posts
    3

    How to use a conditional to insert text into a cell based on a number (count) in a cell

    Hi,

    In my spreadsheet, I would like for a sentence (strings of text) from another worksheet to appear in a certain cell in another worksheet when a certain number is displayed. For example, If cell A1 shows 5, then I would like to have a function or formula to find the related '5' in the table with the text and print out the text found for the matching row into cell B1. I know that I can do this with a simple IF statement, but the problem is that the table with the text is 80 rows long already (and will probably grow a bit more) so that would be a lot of manual work and nested IF statements.

    Is there a better way? Would this require VBA?

  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,939

    Re: How to use a conditional to insert text into a cell based on a number (count) in a cel

    Hi, welcome to the forum

    Have you tried using VLOOKUP() yet?

    A
    B
    C
    D
    1
    2
    bb
    1
    aa
    2
    2
    bb
    3
    3
    cc
    4
    4
    dd
    5
    5
    ee

    B1=VLOOKUP(A1,$C$1:$D$5,2,0)
    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

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

    Re: How to use a conditional to insert text into a cell based on a number (count) in a cel

    Another option based on Ford's data table...

    This formula entered in B1:

    =INDEX(D1:D5,A1)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    04-15-2015
    Location
    earths
    MS-Off Ver
    2013
    Posts
    3

    Re: How to use a conditional to insert text into a cell based on a number (count) in a cel

    I am trying out the vlookup but I am getting the error message 'Value Not Available' error. Not really sure why as it is pretty straight forward equation. I am going to keep playing around with it.

    Tony - I will try your method now as well. Perhaps it will work!

  5. #5
    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,939

    Re: How to use a conditional to insert text into a cell based on a number (count) in a cel

    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.

  6. #6
    Registered User
    Join Date
    04-15-2015
    Location
    earths
    MS-Off Ver
    2013
    Posts
    3

    Re: How to use a conditional to insert text into a cell based on a number (count) in a cel

    Actually I got the vlookup to work! My array was located on a different sheet but I didn't explicity say that in the formula (hence the error.) But it's now working great. Thank so much for your help!

  7. #7
    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,939

    Re: How to use a conditional to insert text into a cell based on a number (count) in a cel

    Awesome

    If this answered your question, please take a moment to mark the thread as "solved" - it helps keep things neat and tidy lol, and consider adding the reputation to those that helped (see points 2 & 3 below my 1st post to you)

+ 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. lock and insert formula in a cell based on selection of text in another cell
    By alirazafazal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2014, 06:08 AM
  2. If cell equals a text then insert a number, (text cell comes from a data validation)
    By floridashaughn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2014, 03:24 PM
  3. [SOLVED] Event Macro to insert text in cell based on input of another cell
    By nplouffe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-08-2012, 11:54 AM
  4. [SOLVED] Insert text to cell based on whether the value begins with a letter or number.
    By BPSJACK in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-23-2012, 09:57 AM
  5. Insert Rows Based on Cell Count
    By PY_ in forum Excel General
    Replies: 2
    Last Post: 10-29-2010, 10:52 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