+ Reply to Thread
Results 1 to 9 of 9

Searching for a character when typed next to a number.

  1. #1
    Registered User
    Join Date
    03-21-2013
    Location
    wa
    MS-Off Ver
    Excel 2007
    Posts
    4

    Searching for a character when typed next to a number.

    Currently need a formula that will:
    1. Check if the range of cells is a number
    2. If the original if statement is true, it searches for a + symbol next to the number returning X if true and removing 1 from length (to get rid of the + symbol) and a " " if false.
    3. If the original if statement is false it returns a " "

    This is what I have:

    =IF(C7:D7=ISNUMBER,=IF((SEARCH("+",C7:D7)),"X & =LEFT(C7:D7, LEN(C7:D7)-1)"," ")," ")

    But something is wrong with the second argument.

    Thanks in advanced.
    Last edited by blynx; 03-21-2013 at 12:54 PM. Reason: Spelling

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Searching for a character when typed next to a number.

    blynx,

    Welcome to the forum!
    Can you provide some sample data with expected results?
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Searching for a character when typed next to a number.

    Theres a lot wrong with that formula

    =IF(ISNUMBER(C7:D7),IF((SEARCH("+",C7:D7)),"X & LEFT(C7:D7, LEN(C7:D7)-1)"," ")," ")

    but it will always come up with error on search("+",C7:D7)
    what are you trying to do?

    is the number with + next to it text? as number format wont show the + sign.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

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

    Re: Searching for a character when typed next to a number.

    Hi and welcome to the forum

    as suggested, please upload a sample workbook, showing the data you are working with, a few sample answers and how you arrived at that.

    Having said that, you cannot to a search for a + in a string of numbers - if those numbers return a value in the cell. For instance, you cannot search for + in a cell that contains +10 - excel sees the answer of the calc, not the formula behind the answer. If on the other hand, you are searching for a + in a text string,, then search will find +, but you cannot "search" a range, only a cell, so you may have to use a helper column to search each cell individually, and then use that in your calcs.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    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
    Registered User
    Join Date
    03-21-2013
    Location
    wa
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Searching for a character when typed next to a number.

    3DAYSPREADSHEET.xlsx

    Basically I have a Non-Tax and Tax column that needs to be filled with a numeric value. What I want is if I added something like "+" next to the entered numeric value (row 7), it would check for a "+" and remove it and place an X in the Cash column (row 8).

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Searching for a character when typed next to a number.

    Where would you enter the +? Would you enter it manually or would it be pulled from the data on sheets 'DAY1', 'DAY2, 'DAY3'? In which column on 'TOTAL' do you want to check the Non-tax and Tax columns for the + symbol? In which column do you want the value with the removed + symbol? There's basically no data at all in your provided example so I'm a bit confused on what you're actually looking for. You also didn't provide any expected results so there's nothing to compare against.

  7. #7
    Registered User
    Join Date
    03-21-2013
    Location
    wa
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Searching for a character when typed next to a number.

    It is on the sheet "DAY1". Row 7 is the entered, Row 8 is the expected.

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Searching for a character when typed next to a number.

    Ahh, ok. In that case what you're looking for is a macro.

    How to use a macro:
    1. Make a copy of the workbook the macro will be run on
      • Always run new code on a workbook copy, just in case the code doesn't run smoothly
      • This is especially true of any code that deletes anything
    2. In the copied workbook, press ALT+F11 to open the Visual Basic Editor
    3. Insert | Module
    4. Copy the provided code and paste into the module
    5. Close the Visual Basic Editor
    6. In Excel, press ALT+F8 to bring up the list of available macros to run
    7. Double-click the desired macro (I named this one tgr)


    Here is the macro code:
    Please Login or Register  to view this content.


    Note that you will have to save the workbook as a .xlsm file instead of .xlsx. When you close and reopen the file, you will need to enable macros in order to run it.

  9. #9
    Registered User
    Join Date
    03-21-2013
    Location
    wa
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Searching for a character when typed next to a number.

    Wow that is amazing. Looks like I should learn visual basic!

+ 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