+ Reply to Thread
Results 1 to 9 of 9

Need to search for a specific string in Column A and delete values within the same row

  1. #1
    Registered User
    Join Date
    01-31-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Need to search for a specific string in Column A and delete values within the same row

    Hi all,

    I have a spreadsheet with values in Columns A:AP. Most of these values in Column A are 4 digit numbers but once in a while the value will be "Group key". The number of rows in the spreadsheet varies from week to week, as does the placement of the cells that read "Group key". It will always be in Column A but the row number is impossible to predict. Also, there can be multiple instances of the "Group key" cells in the same spreadsheet. What I need is a code that will find ALL instances of "Group key" in column A, and then clear the values in columns D through AP within the row that the cell with "Group key" is found. I know how to write code to delete the entire row, but I need to keep the row and just clear values in the columns I mentioned.

    Thanks for any help!
    Last edited by hgeo24; 02-27-2014 at 03:18 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Need to search for a specific string in Column A and delete values within the same row

    This code will be almost identical.
    In the one for whole rows you will have something like
    Please Login or Register  to view this content.
    in the case described you need something like:
    Please Login or Register  to view this content.
    instead
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    01-31-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need to search for a specific string in Column A and delete values within the same row

    Hi Kaper,

    Thanks for your input. Here is the code I have that deletes the whole row:

    Please Login or Register  to view this content.
    How can I modify this to clear Columns D:AP in that row rather than deleting entire row?
    Last edited by hgeo24; 02-27-2014 at 03:53 PM.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to search for a specific string in Column A and delete values within the same row

    hgeo24,
    Please use code tags with your code.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Need to search for a specific string in Column A and delete values within the same row

    For instance:
    Please Login or Register  to view this content.
    PS1: As you do not delete contents the loop can be either bottom->up (step -1) as it is now or top->down (more natural)
    Please Login or Register  to view this content.
    PS2: code tags improve readability of post (and are required by forum rules) so my kind suggestion - edit your post.

  6. #6
    Registered User
    Join Date
    01-31-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need to search for a specific string in Column A and delete values within the same row

    Thank you AB33 and Kaper for the suggestions, however when I used the codes that you both suggested it still deletes the entire row containing "Group key" in column A. Note: i have tagged my most with code as such.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to search for a specific string in Column A and delete values within the same row

    Please Login or Register  to view this content.
    should not be

    Please Login or Register  to view this content.
    ?

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Need to search for a specific string in Column A and delete values within the same row

    No way, it:
    Please Login or Register  to view this content.
    deletes whole rows. No way.

    (Ok if there are some event handling procedures or something special, but normally - no way)


    The same I can say about starting from column D and resizing 39 (not checked this number) columns. and clearcontents.


    A side comment on:

    >0
    vs
    =1

    The latter works only if the text is leftmost in the string. The first works also with "Blah blah Group key blah blah ..." in column A
    Last edited by Kaper; 02-27-2014 at 04:44 PM.

  9. #9
    Registered User
    Join Date
    01-31-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need to search for a specific string in Column A and delete values within the same row

    You are correct. I just typed the code into it's own module and it worked perfectly. Not sure if I had made a typo or what, but it works now.
    Thank you for your 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. Loop to search specific names in column and delete other rows
    By EJ_2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2013, 01:28 PM
  2. Replies: 4
    Last Post: 10-28-2013, 10:57 AM
  3. [SOLVED] Search for multiple string values in the first row of a table and format column values.
    By Excel_junky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2013, 12:48 PM
  4. Replies: 1
    Last Post: 04-23-2012, 10:27 AM
  5. Delete rows with specific column values
    By koklok in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2008, 01:51 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