+ Reply to Thread
Results 1 to 8 of 8

Replace empty string with null

  1. #1
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Replace empty string with null

    Hi all,

    I'm working with some data exported from a database. Unfortunately, when data is exported to excel, cells that should be completely blank (i.e. ISBLANK formula would return TRUE) actually contain empty strings.

    What is the fastest way to replace the empty string with a true null?

    Thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,163

    Re: Replace empty string with null

    What do you mean by "empty strings"?

    The only way I know of entering an empty string in Excel that looks blank but causes ISBLANK to be FALSE is a single quote. The single quote tells Excel that the following characters are to be treated as a string, but the quote itself is not displayed in the cell. It is, however, visible in the formula box. Is that what you have?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Replace empty string with null

    When I say empty string I mean a cell with that appears blank/null but actually has an empty string in i.e ""

    For example if you type the following formula into cell B1:

    =IF(A1=1,"Yes","")

    If cell A1 does not equal 1 the formula will return "" which is an empty string. Excel treats a cell containing an empty string differently to a cell which is actually blank/null.
    The problem I have is the system I have exported data from instead of creating blank cells creates cells with empty strings in At present I know two ways of changing the cells with empty string to true null/blank cells:
    1. Select each cell and click delete/clear contents
    2. Use text to columns and set the column format as general.

    Both of these methods are time consuming, particularly considering the quantity of data in question. I was hoping there might be a more efficient method?

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Replace empty string with null

    Hi,

    Perhaps:

    Please Login or Register  to view this content.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Registered User
    Join Date
    04-04-2014
    Location
    new york city
    MS-Off Ver
    Excel 2003
    Posts
    1

    How to deal with null values in oracle table?

    i have populated a big table from excel, the excel has empty cells i have replace them with ""( empty string) with an if condition now again ihave to read from that table and send it to another table using VB.NET. i get an error "dbnull".....
    can anyone anyone please helps

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,163

    Re: How to deal with null values in oracle table?

    Quote Originally Posted by Emily12 View Post
    i have populated a big table from excel, the excel has empty cells i have replace them with ""( empty string) with an if condition now again ihave to read from that table and send it to another table using VB.NET. i get an error "dbnull".....
    can anyone anyone please helps
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,163

    Re: Replace empty string with null

    anteagles20, I think XOR LX has an appropriate solution.

    However, let me clarify one thing about your description. Your original post said you were importing from a database. That seems to preclude formulas, so I considered only constant values in cells. Your further explanation talked only about the result of formulas, a different matter. When you talk about how "Excel treats a cell containing an empty string" you are actually talking about how Excel treats a cell containing a formula that returns an empty string. The definition of ISBLANK is to return TRUE if the cell is empty; a cell with a formula is not empty, even if the value of that cell is the empty string.

  8. #8
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Replace empty string with null

    Thanks XOR, i have used your code (with the removal of the select statement).

    6StringJazzer: I meant the formula only as an example to illustrate how you may end up with a cell containing a null string. As stated in the original post the cells do not contain formulas, just null strings. Thanks for your input.

    Thanks again

+ 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. Find a cell that has a null value, and replace with an empty string.
    By skania in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2013, 12:49 PM
  2. If null be empty
    By hawkins in forum Excel General
    Replies: 1
    Last Post: 06-22-2012, 12:48 PM
  3. How to test the entire row if it is empty or null?
    By annir in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2008, 09:28 PM
  4. Code to replace null and not null strings
    By tigertim71 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2008, 05:07 PM
  5. Replace null string with blank cell
    By gjcase in forum Excel General
    Replies: 2
    Last Post: 08-09-2005, 09:13 AM

Tags for this Thread

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