+ Reply to Thread
Results 1 to 10 of 10

If condition is met, clear the cell next to it.

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    If condition is met, clear the cell next to it.

    I want to add to this that it clears the cell to its right. That is it. No deleting or clearing entire row. The range changes. Can I just do some kind of "offset"? All i find online is trying to clear an entire row or is when the range is set.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: If condition is met, clear the cell next to it.

    Hello taylorsm,

    Your snippet Code is too incomplete to guess how you want us to magically solve your issue, for me, at least.

    Please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: If condition is met, clear the cell next to it.

    Try
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    or
    many more possiblities
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: If condition is met, clear the cell next to it.

    Jolivanes, thank you. I think your last one is the closet. I can't try right now but will shortly. I don't think you can say to clear any specific range because that will change. It is dependent on the location of the searched word.

    Winon, attached is a sample sheet.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: If condition is met, clear the cell next to it.

    If, like in the attached example, test3 is always in Column A, the first example would be the way to go.
    If there also would be only one time "test3" in that column, you should have an "Exit Sub" in there so it quits going through all the cells after it found the only one.
    If test3 could be anywhere, the UsedRange suggestion would work

    For only one time "test3"
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: If condition is met, clear the cell next to it.

    No. Won't always be in the same column. This is the full macro I use.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: If condition is met, clear the cell next to it.

    Try this on a copy of your workbook after extending the arrays.
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: If condition is met, clear the cell next to it.

    Hello Taylorsm,

    You could place all the names in a drop down, select the name whose offset(0,1) value you wish to clear then execute the code to clear that value.

    Would this method work for you? I've attached an example for you to have a look at. Click on "GO" to execute the code.

    The code would be something as follows:-

    Please Login or Register  to view this content.
    Cheerio,
    vcoolio.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: If condition is met, clear the cell next to it.

    If it is indeed just a single name in all these ranges, this could be another approach.
    vcoolio's approach might be better as it might help with spelling mistakes.
    Please Login or Register  to view this content.
    I assume, more then likely wrongly so, that there is a reason to have these blocks of ranges.
    If not, the UsedRange method could be the way to go.
    Last edited by jolivanes; 01-27-2018 at 01:19 AM. Reason: Add On Error statement

  10. #10
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: If condition is met, clear the cell next to it.

    @ Jolivanes:

    I assume, more then likely wrongly so, that there is a reason to have these blocks of ranges.
    I was wondering about the "blocks" also.

    However, the OP now has a few options to play with.

    Cheerio,
    vcoolio.

+ 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] Clear Cell with Condition
    By hkbhansali in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-14-2018, 10:29 AM
  2. Clear cell contents of drop down box based on condition
    By Pami in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-29-2015, 12:05 PM
  3. Clear Cell with Condition
    By RoMarius1981 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-04-2013, 07:18 AM
  4. Replies: 1
    Last Post: 06-21-2013, 04:05 AM
  5. Automatically Clear Rows When Condition Is Met
    By TheLostBoy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-07-2009, 03:49 AM
  6. Clear Contents in Specific Rows via condition
    By Excel Newbie05 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-09-2008, 04:02 PM
  7. [SOLVED] Clear contents with condition
    By Vanna in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2006, 11:10 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