ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Allow value in only one of two cells (https://www.excelbanter.com/excel-programming/399965-allow-value-only-one-two-cells.html)

CLR

Allow value in only one of two cells
 
Hi All........

Having trouble here trying to build a toggle to allow an entry in only one
of two cells.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$K$10" Then
Range("k11").Value = ""
Range("K10").Value = "CRA"
Else
End If
If Target.Address = "$k$11" Then
Range("k10").Value = ""
Range("K11").Value = "CRA"
Else
End If
End Sub

The first IF works fine, the second one don't work at all.

Any help would be appreciated.

TIA
Vaya con Dios,
Chuck, CABGx3


Gary''s Student

Allow value in only one of two cells
 
If Target.Address = "$K$11" Then

the k must be uppercase
--
Gary''s Student - gsnu200751


"CLR" wrote:

Hi All........

Having trouble here trying to build a toggle to allow an entry in only one
of two cells.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$K$10" Then
Range("k11").Value = ""
Range("K10").Value = "CRA"
Else
End If
If Target.Address = "$k$11" Then
Range("k10").Value = ""
Range("K11").Value = "CRA"
Else
End If
End Sub

The first IF works fine, the second one don't work at all.

Any help would be appreciated.

TIA
Vaya con Dios,
Chuck, CABGx3


CLR

Allow value in only one of two cells
 
" Oh for crying out loud!".............

Thank you kind Sir.........

Vaya con Dios,
Chuck, CABGx3



"Gary''s Student" wrote:

If Target.Address = "$K$11" Then

the k must be uppercase
--
Gary''s Student - gsnu200751


"CLR" wrote:

Hi All........

Having trouble here trying to build a toggle to allow an entry in only one
of two cells.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$K$10" Then
Range("k11").Value = ""
Range("K10").Value = "CRA"
Else
End If
If Target.Address = "$k$11" Then
Range("k10").Value = ""
Range("K11").Value = "CRA"
Else
End If
End Sub

The first IF works fine, the second one don't work at all.

Any help would be appreciated.

TIA
Vaya con Dios,
Chuck, CABGx3


Dave Peterson

Allow value in only one of two cells
 
I like this style to avoid that problem:
If not (intersect(Target, me.range("k10")) is nothing) then



CLR wrote:

Hi All........

Having trouble here trying to build a toggle to allow an entry in only one
of two cells.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$K$10" Then
Range("k11").Value = ""
Range("K10").Value = "CRA"
Else
End If
If Target.Address = "$k$11" Then
Range("k10").Value = ""
Range("K11").Value = "CRA"
Else
End If
End Sub

The first IF works fine, the second one don't work at all.

Any help would be appreciated.

TIA
Vaya con Dios,
Chuck, CABGx3


--

Dave Peterson


All times are GMT +1. The time now is 01:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com