+ Reply to Thread
Results 1 to 10 of 10

Excel VBA - To clear contents if cell in same row contains value

  1. #1
    Registered User
    Join Date
    09-12-2019
    Location
    Malta
    MS-Off Ver
    Office 365 ProPlus Version 1904
    Posts
    6

    Excel VBA - To clear contents if cell in same row contains value

    Hello Geniuses,

    Seeking some advice / help hence in need of some wisdom. I want VBA to clear the contents of a cell IF another cell in the same row contains 'OK'

    This is the data I have:

    Excel.JPG

    Into some more detail: I was looking for VBA to clear the contents of the respective cell in column G if the adjacent status in column I is 'OK'
    This needs to be applied to the whole active worksheet whereas if the status for that row shows 'OK' then the respective 2nd FollowUp date in the same row is not needed hence needs to be cleared.

    I was currently trying to tweak the current code (found it online - not my work) but got little ahead so far:

    Please Login or Register  to view this content.
    Any help getting through this will be greatly appreciated.

    Many thanks!

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

    Re: Excel VBA - To clear contents if cell in same row contains value

    Hello KriKri84,

    Is the status in Column I the result of a formula or is it just typed in when required or is it a selection from a drop down?

    Cheerio,
    vcoolio.

  3. #3
    Registered User
    Join Date
    09-12-2019
    Location
    Malta
    MS-Off Ver
    Office 365 ProPlus Version 1904
    Posts
    6

    Re: Excel VBA - To clear contents if cell in same row contains value

    Hello vcoolio,

    It is the result of a formula I created from another tab on the same workbook:

    Attachment 644544

    Thanks!!

  4. #4
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Excel VBA - To clear contents if cell in same row contains value

    One way with filter
    Please Login or Register  to view this content.
    Last edited by nigelog; 10-09-2019 at 06:00 AM.

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

    Re: Excel VBA - To clear contents if cell in same row contains value

    Hello KriKri84,

    It is the result of a formula I created from another tab on the same workbook:
    If that's the case, and your data set is large, I was going to suggest using autofilter but Nigelog has already done this. Test his solution and let us know how it works (test it in a copy of your workbook first).

    Cheerio,
    vcoolio.

  6. #6
    Registered User
    Join Date
    09-12-2019
    Location
    Malta
    MS-Off Ver
    Office 365 ProPlus Version 1904
    Posts
    6

    Re: Excel VBA - To clear contents if cell in same row contains value

    Amazing! Works beautifully and it is exactly what I wanted!!

    However I realized that column G needs to be visible for the code to work. Columns F / G/ H will be hidden from the user.

    Is there any way we can fix this from the code? My apologies for not mentioning it earlier but I was not even aware it mattered.

    Much obliged!

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,120

    Re: Excel VBA - To clear contents if cell in same row contains value

    How about
    Please Login or Register  to view this content.

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Excel VBA - To clear contents if cell in same row contains value

    Please Login or Register  to view this content.
    unhide and hide columns will work
    Last edited by nigelog; 10-09-2019 at 08:54 AM.

  9. #9
    Registered User
    Join Date
    09-12-2019
    Location
    Malta
    MS-Off Ver
    Office 365 ProPlus Version 1904
    Posts
    6

    Re: Excel VBA - To clear contents if cell in same row contains value

    Works like a charm!

    Thank you so much vcoolio / nigelog!

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

    Re: Excel VBA - To clear contents if cell in same row contains value

    You're welcome KriKri84 (although Nigelog did the bulk of the work on this.)

    Please also acknowledge Fluff13's contribution.

    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. excel clear cell contents if another cell changes
    By Cindi Novell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2019, 09:54 AM
  2. [SOLVED] Clear Contents depending on cell contents
    By terratushi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2017, 08:02 PM
  3. [SOLVED] Needing VBA code to clear contents of cell when the contents of another cell is cleared
    By jeh0714 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-15-2016, 03:49 PM
  4. Clear merged cell contents in comand button(clear all)
    By mohan_984 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-25-2015, 10:39 AM
  5. [SOLVED] Clear contents based on contents of another cell
    By Katrina DTE in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-13-2013, 02:44 PM
  6. [SOLVED] Clear contents of last used cell in a range and those previous to it (excel 2003)
    By chris_norton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2012, 02:06 PM
  7. [SOLVED] [SOLVED] Excel should let me clear cell contents without clearing formulas
    By BJM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2005, 01:00 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