BrendanDixon
Board Regular
- Joined
- Mar 7, 2010
- Messages
- 174
- Office Version
- 365
- 2019
- Platform
- Windows
Hi All,
I am creating a sheet with 2 columns and if I select the column it will fill it with an X and clear the other column please can someone help me with the part where is will clear only the other cell in that row. I could use allot of code to do each row individually. but I am sure there is a better way of doing this so I can learn from this. basically it will be from rows 18 to 34 and columns B and C
I am creating a sheet with 2 columns and if I select the column it will fill it with an X and clear the other column please can someone help me with the part where is will clear only the other cell in that row. I could use allot of code to do each row individually. but I am sure there is a better way of doing this so I can learn from this. basically it will be from rows 18 to 34 and columns B and C
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Cell As Range
If Not Intersect(Target, Range("B18:C34")) Is Nothing Then
Cancel = True
For Each Cell In Range("B18:C34")
If Not Intersect(Cell, Target) Is Nothing Then
Cell.Value = "X"
Else
'This is where to clear other cell in the row
Cell.MergeArea.ClearContents ' This will need to change
End If
Next
End If
End Sub