+ Reply to Thread
Results 1 to 5 of 5

Delete Each Instance of a String in a Range

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Delete Each Instance of a String in a Range

    This should be easy, so it's no wonder I'm having trouble with it.

    In column A I have a list of main categories
    In column B I have a list of sub-categories
    In column C I have a list the main catagories that each of the sub-categories in column B belongs to.

    All of the values in column A and B are unique
    Many of the values in column C are dupicate (since a main catagory could have several sub-catagories).


    I would like for 2 things to happen when the user deletes a main catagory

    1. The name of the main catagory gets deleted from colunm A.

    2. Each instance of the main category name in column C will also be deleted, as well as the corresponding sub-category in column B.


    Not sure if this is clear or not, but please see the attached workbook. It shows a "before" and "after" of what I'm looking to achieve.

    thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: Delete Each Instance of a String in a Range

    Insert a standard module to store a global variable to hold the selected cell's previous value (before deletion)
    Please Login or Register  to view this content.
    Then in the worksheet module that has your data, insert this code, which uses SelectionChange and Change events to adjust your data when a main category is deleted. (Hopefully!)
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Delete Each Instance of a String in a Range

    Hi, and thanks for your response.

    Forgive me if I'm being dense, but it looks like your code is designed to be triggered when a user deleted a main category off the actual worksheet. I'm sorry for not stating so in the beginning, but the worksheet will be hidden and the user will just see the names of the parent/children in 2 list boxes on a user form. So the user would click on either the parent or child (as the case may be),and then hit a "delete" button.

    Does that affect your code?

  4. #4
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Delete Each Instance of a String in a Range

    Actually, I was able to figure it out. Thanks for putting me on the right track!

  5. #5
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: Delete Each Instance of a String in a Range

    You're welcome. Glad you got it working!

+ 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] Delete range if met a string condition
    By oddy73 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2015, 11:21 AM
  2. For each instance of word in string
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2015, 07:05 PM
  3. [SOLVED] Replacing the second instance of a string within another string.
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2013, 09:44 AM
  4. nth instance of a character in a string
    By AndrewMac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2013, 11:20 AM
  5. Find nth instance of a character in a string
    By BRISBANEBOB in forum Excel General
    Replies: 1
    Last Post: 12-26-2011, 07:09 PM
  6. Finding the second instance of a value after a text string
    By ryantaylor in forum Excel General
    Replies: 9
    Last Post: 03-02-2011, 11:18 AM
  7. The first instance of a number in a string
    By Tracer123 in forum Excel General
    Replies: 2
    Last Post: 05-21-2008, 11:39 AM

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