简体   繁体   中英

Clear Cell Value based on Condition of another Cell in Excel

Cell A1:A6 has a User Fed value, Cell B1:B6 has a formula, Cell C1:C6 has a result If Cell A1 value is deleted, Can the content be cleared from C1 , I tried this but its not working.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1:A6")) Is Nothing Then
    Range("C1:C6").ClearContents
    End If
End Sub

Try below codes-

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1:A6")) Is Nothing Then
        If Target = "" Or Target = Null Then
            Target.Offset(0, 2).ClearContents
            'Target.Offset(0, 2) = ""
            'Range("C1:C6").ClearContents
        End If
    End If
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM