dpalomino1009
New Member
- Joined
- Mar 3, 2019
- Messages
- 20
Hello, I wanted to know if there was a way to clear cells based on a cell having the same value as cell in a table column range. For example, say we are working with table1, A1:C150, A has names, B has extensions, and C has computer names. If an extension in range B1:150 is the same as D1, B30 happens to match D1 for example, then the code would clear the corresponding cells. I would enter the extension I want cleared out on D1 and the code would clear the matching cells A30, C30 and B30. I attempted to put something together but need help. Noting some ideas I had below. I don't know if there is something that will select the cells that have the same value as D1 in the way that =INDEX(A1:A150,MATCH(D1,B1:B150,0)) would get a value in A1:A150 that matches D1 if found in B1:B150. I appreciate any ideas that you may have. Thank you.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D1")) Is Nothing Then With Sheets("Ext, PC")
"something to select the cell that has the same value as D1".Offset(0, -1).Clear
"something to select the cell that has the same value as D1".Offset(0, 1).Clear
"something to select the cell that has the same value as D1".Offset(0, 0).Clear
End With
End If
End Sub