Forum Discussion
Delete cell contents based on the condition of another cell
- Aug 07, 2021
You need to adopt the VBA approach to achieve this.
The attached file contains a Change_Event Code on Stock Out Sheet Module and as per the code, if you delete the Code in any row, the corresponding Unit will also be deleted.
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo Skip If Target.Column = 3 And Target.Row > 2 Then Application.EnableEvents = False If Target = "" Then Cells(Target.Row, "E") = "" End If End If Skip: Application.EnableEvents = True End Sub
mathetes I like the more simplified approach you have there. However, I've spent quite a bit of time on my currently workbook, and just seem to be hung up on this one issue. I would like to find a solution to this issue if there is one.
This is my first attempt at this, as well as my first official business. Since, you have a lot of experience in this area. Do you think I'm on the right track. Is there any other useful bits of information I should add to this workbook?
This business will be starting off online, until we're able to open up a brick-and-mortar location. I'm Hoping this workbook will serve my needs as the business continues to grow.
You need to adopt the VBA approach to achieve this.
The attached file contains a Change_Event Code on Stock Out Sheet Module and as per the code, if you delete the Code in any row, the corresponding Unit will also be deleted.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Skip
If Target.Column = 3 And Target.Row > 2 Then
Application.EnableEvents = False
If Target = "" Then
Cells(Target.Row, "E") = ""
End If
End If
Skip:
Application.EnableEvents = True
End Sub
- Jlwiv87Aug 07, 2021Copper ContributorThat did the trick! Thank you so much for your help. I'm new to dealing with Excel and have heard about VBA, but haven't got around to using it yet. I will have to explore this more. Thank you for your time and effort!
- Subodh_Tiwari_sktneerAug 07, 2021Silver Contributor
You're welcome Jlwiv87! Glad it worked as desired.