So I have two columns in an excel spreadsheet – only one of those columns should be allowed to have a value in it. Lets call them Cells
I figure that I can facilitate this one of two ways:
A1is changed it blanks out
I can do this but then when it blanks out
B1, it then fires off the same event and both cells get cleared.
If one of the cells has a value in it, then the other is somehow locked for editing until you clear the first cell.
Any tips would be greatly appreciated.
You can disable events to avoid clearing both cells; ie
Private Sub Worksheet_Change(ByVal Target As Range) Dim rng1 As Range Set rng1 = Intersect(Target, Range("A1,C1")) If rng1 Is Nothing Then Exit Sub Application.EnableEvents = False If rng1.Address(0, 0) = "A1" Then [c1].ClearContents Else [a1].ClearContents End If Application.EnableEvents = True End Sub