+ Reply to Thread
Results 1 to 10 of 10

Function or Formula to replace a dynamic string with a NULL value

  1. #1
    Registered User
    Join Date
    08-30-2016
    Location
    St. Louis, MO
    MS-Off Ver
    2016
    Posts
    3

    Function or Formula to replace a dynamic string with a NULL value

    I'm looking for a method to implement something such as a function or formula to replace a dynamic string value with Null/Nothing or even something like a comma or semicolon. I have a spreadsheet with several rows where I constantly have to scrub data in one specific column so I'm looking to save time. The value I want to replace starts with a number (could be anything from 0 - 99999) and ends with a comma ",". I'll call this string JUNK... JUNK can be embedded in the cell several times. So the data pattern in the cell/column could appear as: [useful data string] JUNK [useful data string] JUNK [useful data string]. I'd like it to appear as [useful data string]; [useful data string]; [useful data string]

    Please Help!

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Function or Formula to replace a dynamic string with a NULL value

    You might be able to do it with some complicated combination of LEFT/MID/SUBSTITUTE/FIND/SEARCH, possibly with the help of some helper columns, but it will depend entirely on the make-up of the [useful data string] and the [junk].

    For example, it might be possible to do it with this mix of useful letters and junk numbers:
    thisisuseful123,soisthis456,andthis7890,
    making it into:
    thisisuseful;soisthis;andthis

    But this, with both useful data and junk being a mix of letters and numbers, would be impossible:
    thisnumber12isuseful99junk99,andthisnumber34too98junk98,andthis56aswell97junk97,

    The reason is that there would be no way of knowing that the correct scrubbed version should be:
    thisnumber12isuseful;andthisnumber34too;andthis56aswell
    instead of:
    thisnumber;andthisnumber;andthis
    or:
    thisnumber12isuseful99junk;andthisnumber34too98junk;andthis56aswell97junk

    Can you upload a sample file to let us see what sort of combinations you have? We can then let you know if it's possible but difficult, or impossible.
    (Click 'Go Advanced' below the reply box, then 'Manage Attachments' - make sure you don't include any confidential data.)
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,719

    Re: Function or Formula to replace a dynamic string with a NULL value

    I agree that having a more rigorous definition of what your data looks like is essential.

    I am also inclined to say this should be solved with VBA. regex pattern matching is ideal for this sort of thing.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    08-30-2016
    Location
    St. Louis, MO
    MS-Off Ver
    2016
    Posts
    3

    Re: Function or Formula to replace a dynamic string with a NULL value

    Thank you. Attached is a file name Export.xlsx Column is Client Submissions. What I'm trying to do is eliminate everything BUT the names of people.
    Attached Files Attached Files

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Function or Formula to replace a dynamic string with a NULL value

    Not sure I understand the requirements. The upload doesn't seem to match the description.

    Assuming 'junk' is in the pattern "###:" I tried this anyway.

    There is a 'new' feature starting in Excel 2013 called Flash fill.

    These are the steps I took:
    1. Apply filter to the data.
    2. Filter out Blanks in column B.
    3. Choose the most complex string (most "####:").
    4. I chose "101:Sr. Project Coordinator, James Schaefer ; 100:Sr. Project Coordinator, Sharon Peetro" from row 7.
    5. I copy/pasted that single item in D7.
    6. I deleted all the 'junk'.
    7. With that cell active click Data > Flash fill.
    8. Then remove Filters.

    This worked at my end with the example posted.
    Last edited by FlameRetired; 08-30-2016 at 07:20 PM.
    Dave

  6. #6
    Registered User
    Join Date
    08-30-2016
    Location
    St. Louis, MO
    MS-Off Ver
    2016
    Posts
    3

    Re: Function or Formula to replace a dynamic string with a NULL value

    Thanks Dave. Beautiful... With me being a geek, I'd like to also figure out how to do it programatically too - but that is great, thank you!

  7. #7
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Function or Formula to replace a dynamic string with a NULL value

    to me it looks like the values you want are after , and if there is a ; we want to look for a second, third etc , character.

    are they all formatted like this?

    Anyway, try something like this if so (in C2):

    Please Login or Register  to view this content.
    you can add onto the end of it in the same way for further names if needed, idk how many iterations you would need... Got slightly confused towards the end of it myself, a little tired...

    anyway you just need to reference where the stuff is to get it to work.

    For instance,

    Please Login or Register  to view this content.
    finds the second occurrence of "," which solves the issue. You'd have to nest that again for a third occurrence, etc. So, as you can see, this formula format will very quickly get out of control, but it will work...

    Going to bed now, gl
    Last edited by TheN; 08-30-2016 at 11:27 PM. Reason: Better Explanation

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Function or Formula to replace a dynamic string with a NULL value

    You're welcome. Thanks for the feedback.

    Afraid I can't help you with a VBA solution. It's my short suit, but standby. I'm sure someone is watching.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Function or Formula to replace a dynamic string with a NULL value

    sryme,

    There is a User Defined Function written by tigeravatar that I often find useful. You can find it here:
    http://www.excelforum.com/tips-and-t...ml#post3096647

    Try this array-entered formula in D4 (filtered out blanks, again) and filled down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

    The syntax of that function is =concatall(array or range, separator). I used "" for the separator.

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,719

    Re: Function or Formula to replace a dynamic string with a NULL value

    Here is a VBA solution that provides a UDF to take a cell and return the cleaned-up version. The original cell from column A remains intact and I show the result of using function StripNum in the last column.

    If instead, you want to sweep through column A and update the actual cells, then a change to the code is needed. Small change, let me know what you need.
    Attached Files Attached Files

+ 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. [SOLVED] Replace empty string with null
    By anteagles20 in forum Excel General
    Replies: 7
    Last Post: 04-08-2014, 07:16 AM
  2. [SOLVED] Need help with REPLACE function to replace HEX A0 with HEX 20 in string
    By flyboy54 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2013, 12:52 PM
  3. 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
  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. Function returning null value instead of string value
    By shivboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2006, 08:45 AM
  6. Replies: 0
    Last Post: 10-13-2005, 02:05 PM
  7. 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