+ Reply to Thread
Results 1 to 3 of 3

Clear Cell range upon Changing data in difference Range

Hybrid View

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Clear Cell range upon Changing data in difference Range

    I am currently using the below code to clear the data in cells K14:O48 if data in A14:B48 changes.

    The problem is, if i change data in cells NOT in the A14:B48 range, Data in K:O clears as well. How do I stop that from happening?

    Also, is there a way to change the code so that ONLY the row with changed numbers in A and B is cleared in k:o?

    (so if i only change info in cell A16, then k16:o16 clears, but the rest remains)


    Private Sub Worksheet_Calculate()
      Dim c As Range
        Application.EnableEvents = False
          For Each c In Range("A14:B48")
            If c.Value <> 0 Then
               Range(Cells(c.Row, "K"), Cells(c.Row, "O")).ClearContents
            End If
          Next c
        Application.EnableEvents = True
    End Sub
    Last edited by snuffnchess; 04-08-2016 at 01:22 AM.

  2. #2
    Forum Contributor
    Join Date
    06-02-2015
    Location
    delhi
    MS-Off Ver
    2010
    Posts
    104

    Re: Clear Cell range upon Changing data in difference Range

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Application.EnableEvents = False
    If Not Intersect(Target, [A14:B48]) Is Nothing Then
            
            Range(Cells(Target.Row, "K"), Cells(Target.Row, "O")).ClearContents
    End If
    Application.EnableEvents = True
    
    End Sub

    'Made by :- Mandeep baluja
    'https://www.facebook.com/groups/825221420889809/
    'https://www.linkedin.com/in/mandeep-baluja-b777bb88
    Add Reputation if it helps

  3. #3
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Clear Cell range upon Changing data in difference Range

    Thank you so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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