+ Reply to Thread
Results 1 to 7 of 7

Macro to Clear Cell Content based on a condition

  1. #1
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Macro to Clear Cell Content based on a condition

    Hi Everyone.. I have a workbook where I have a drop down in column A with different Names and "Other". I want contents of column E , F and G in the same row to be deleted when i select any name from the drop down.
    If I select "Other" in drop down in column A then I should be able to type as free text in column E, F and G.
    Columns E, F and G just have dependent data validation running based on the selected name in column A.
    The problem is if I select a name in column A and then toggle back to Other, the contents of column E, F and G are still there.
    How can I clear the contents of cells in column E , F and G. If I can do without VBA then it will be great but if not then I am happy to apply the code as well to get it done.

  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: Macro to Clear Cell Content based on a condition

    Hello pchugh,

    Columns E, F and G just have dependent data validation running based on the selected name in column A.
    The problem is if I select a name in column A and then toggle back to Other, the contents of column E, F and G are still there.
    There are many ways how you could have done that, and I don't Think Forum Members would like to Guess, or hear how you have done it.

    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
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Re: Macro to Clear Cell Content based on a condition

    Hi Winon.. I found the below VBA in another thread and its actually working fine for me with just one problem. It just works on one row. How can I extend this down to other rows.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B4")) Is Nothing Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    Range("B6").ClearContents
    End Sub

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

    Re: Macro to Clear Cell Content based on a condition

    Hi pchugh,

    You could try it this way;

    Please Login or Register  to view this content.
    And that is as far as my guessing will go. Without a sample Workbook, I would not be able to further assist you. Sorry.

    Regards.

  5. #5
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Re: Macro to Clear Cell Content based on a condition

    Hi Winon. I wanted to extend this down to rows. Currently it just works with changing values on row B4. How can I get this to work on B5, B6 and so on to clear contents in column E, F and G.

    If Intersect(Target, Range("B4")) Is Nothing Then Exit Sub

    If something we can change to extend this to complete column B will be great to work for me.

    Sorry I dont have a sample workbook and I am not allowed to post any data on public forums. If you can help on this one then it will be really appreciated.

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

    Re: Macro to Clear Cell Content based on a condition

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Re: Macro to Clear Cell Content based on a condition

    Hi Winon.. I am still having problem with this code. I want this code to run line by line. Look at B14 and clear contents on E14, F14 and G14. Then look at B15 and clear contents in E15, F15 and G15 and so on.
    If i use the below code then any activity in row B4:B40 clear any contents in range E6:E40.. this is what I dont need it to do..
    How can I achieve the below code to run line by line only. This one is looking at B14. How can I make it look at B15 and so on to clear contents in corresponding rows.

    Please Login or Register  to view this content.

+ 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. Clear cell content based on cell values
    By Excelski in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2017, 11:25 AM
  2. [SOLVED] Macro to Clear content after specific cell
    By kasun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2015, 01:45 PM
  3. 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
  4. Clear cell content based on calculated value in another cell
    By DVP2010 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-02-2014, 11:13 AM
  5. Replies: 3
    Last Post: 08-16-2014, 09:55 AM
  6. Clear cell content based on another cell calculation
    By zozo23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2012, 03:10 PM
  7. Lock and clear cell content based on another cell's value
    By mohitmahajanin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2008, 06:30 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