+ Reply to Thread
Results 1 to 16 of 16

IF Command

  1. #1
    Registered User
    Join Date
    06-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    28

    IF Command

    Hi All

    How could I write an ‘If’ command that replaces values smaller than -5 in the previous column of data (J in this case) with a blank cell? I want then to delete all blank cells.
    I am trying
    =If (J2<-5, blank, J2)
    =If (J2<-5, , J2)
    =If (J2<-5, A , J2)

    But with all of them, cells that are lower than -5 are populated with the #Name? error.
    Could anybody please help?

    M Roy

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: IF Command

    Try

    =(IF(J2<-5,"",J2)
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    02-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: IF Command

    Try

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: IF Command

    Hi Both,
    Thanks a lot for your contributions,

    Your formula does the trick however when I come to delete all the empty cells (using F5/Special/Blanks) then my empty cells are not selected. I copy and paste them all (using paste ‘Value’ command) so as to get rid of the F command within the cells, but still Excel doesn’t recognise the empty cells as 'empty'! it simply doesn't select them...

    Any Suggestions?

    I have attached an abbreviated file as the original file has about 90K rows! (It’s 10MB in size).

    Cheers
    Roy
    Attached Files Attached Files

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,498

    Re: IF Command

    your best bet is to do a copy, paste special >> values and this will replace the formulas with blanks, then you can do what you want by deleting the blank cells.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  6. #6
    Registered User
    Join Date
    06-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: IF Command

    Hi Sambo,

    That is exactly what I am doing (special paste>> value), but when I come to select the blank cells (using F5/Special/blank) then empty cells are still not selected (you can try it on the spreadsheet I have attached).
    I would genuinely appreciate any advice :o)
    M. R.

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,498

    Re: IF Command

    well I'll admit to being a bit confused (but not a first for me ) but, for example, cell G2 along with column G in your sample data is/are empty. Col G is a simple delete and everything moves left. To delete cell G2 would mean you'd have to decide if you wanted to shift the surrounding cells either left or up which would alter your remaining information.
    I agree there seems to be a "residue" in those cells after doing the paste special values as when I put my cursor in cell G2 and hold down shift/control and the down arrow it only goes down as far as the last row that held the previous formula, but if you then hit delete it now removes that "residue" and the same action will highlight the entire column to the bottom of the spreadsheet.
    Maybe someone else knows how to get rid of that residue?

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,498

    Re: IF Command

    BTW, if the effort is to isolate rows, you could still apply a filter at the top of the data, even with the residue it still recognizes the blanks as blanks.

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: IF Command

    I cannot identify the character in question that is causing the problem but it appears to be something like a no width space that doesn't have an ANSI code (at least I couldn't find one).
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  10. #10
    Registered User
    Join Date
    06-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: IF Command

    Well my dear friend, welcome to my miserable world of data collection :o)

    The main file is a 3 year compilation of weather data in England (Newcastle upon Tyne). These values are ‘radiant’ temperatures logged by 4 sensors at 4 different orientations of a building.
    Sometimes the transmitter fails to send the temperature and normally all my faulty data are below -5°C. So I want to get rid of all the faulty ones and analyse the rest. Each faulty data means that the entire row then is useless. So unless I have 4 correct readings, all else could be disposed of.
    Using =(IF(J2<-5,"",J2) allows me to make all the incorrect cells into blank and then I can selected them and delete the entire rows. But as you correctly identified there remains some 'residues' in the cells that somehow stops Excel detecting them as empty.
    I have attached half a year worth of data for anybody who wishes to comment. Remember that I have 3 years’ worth of these values…
    WS download_1 May 2014_ For Forum.xlsx
    Thanks Sambo for taking the trouble to investigate this …
    M

  11. #11
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,498

    Re: IF Command

    Just playing around in your latest spreadsheet, a couple options come to mind. One, if all of your data that are below -5C, you could use a conditional format rule to color those cells, then a top row filter to filter on color then highlight all those rows and hit delete. Two, use your formula and then, again using the filter, filter on blanks, highlight those rows and right click delete them. Three, import into Access and using a couple formulas tag those rows for deleting or as garbage then produce reports excluding them.

  12. #12
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: IF Command

    Why don't you use the Filter available on the Data tab?

    Click in your data, click the filter button and filters will appear on the headers of the columns. Choose the column to filter by, choose Number Filter, Less Than and enter -5. All values that meet that criteria will be the only values visible.

    On the Home Tab click on Find & Select, Go To Special, Visible Cells Only. Click OK. Hit the delete key. (cut won't work)

    Click on the Date column filter and Sort the dates in order. All blank rows will be gone.

  13. #13
    Registered User
    Join Date
    06-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: IF Command

    Hi Sambo:

    I can highlight the target cells in red (using the conditional formatting).
    When I apply the filter, I can't delete the target cells from there,

    could you tell me what commands you use step by step?
    Attached is my abridged formatted file !
    Sensor data analysis_2 May 14.xlsx
    Sincere thanks,

  14. #14
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,498

    Re: IF Command

    here it is back w/filter applied. after applying the filter to the top row, click the down arrow to filter, then before you get into the list you'll see filter by color, click that then click on the color you want. This will limit (as seen in what I saved) all those you might want to delete. Then go to the first row of the filtered data, highlight the row, then shift/ctrl down arrow to highlight all the rows, then right click and hit delete. They should all be gone.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    06-30-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: IF Command

    Hi Newdoverman
    Absolutely marvellous. It did work and is really much simpler than the if command.
    Thank you so very much indeed for clarifying this. Greatly appreciate your input…
    M

  16. #16
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: IF Command

    You're welcome.

    Thank you for the feedback. Glad to help.

+ 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. Master Command Button to call on other Command Buttons located in other Workbooks
    By MrNickRegan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2013, 07:57 PM
  2. [SOLVED] Changing ODBC command texts and refreshing via command button
    By milty456 in forum Excel General
    Replies: 2
    Last Post: 10-09-2012, 12:06 PM
  3. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  4. Nest SUM command with a command to make result cell blank
    By dwest185 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-17-2011, 08:10 PM
  5. Using macro to execute a command in Shell Command
    By aadarsh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2010, 07:06 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