ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data validation dependent of value of option button (https://www.excelbanter.com/excel-programming/363790-data-validation-dependent-value-option-button.html)

[email protected]

Data validation dependent of value of option button
 
Hi,

I'm creating a form in Excel in which I want to validate data in a
specific cell dependant of value of an option button elsewhere on the
form. I,ve created code below, but despite the fact I'm not getting any
VB errors there is no validation either, respectless of what value I
put into subject cell or option button.

Can somebody point me in the right direction here? Thx!

Private Sub Worksheet_Change(ByVal target As Range)
If target = "B16" Then
If OptionButton1.Value = -1 Then
With target.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="V6504:V7031"
.IgnoreBlank = True
.InCellDropdown = False
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = "Niet goed. Nog een keer proberen"
.ShowInput = True
.ShowError = True
End With
End If
End If
End Sub


Charlie

Data validation dependent of value of option button
 
I haven't looked at all your code but the first line probably should be:

If Target.Address(False, False) = "B16" Then


" wrote:

Hi,

I'm creating a form in Excel in which I want to validate data in a
specific cell dependant of value of an option button elsewhere on the
form. I,ve created code below, but despite the fact I'm not getting any
VB errors there is no validation either, respectless of what value I
put into subject cell or option button.

Can somebody point me in the right direction here? Thx!

Private Sub Worksheet_Change(ByVal target As Range)
If target = "B16" Then
If OptionButton1.Value = -1 Then
With target.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="V6504:V7031"
.IgnoreBlank = True
.InCellDropdown = False
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = "Niet goed. Nog een keer proberen"
.ShowInput = True
.ShowError = True
End With
End If
End If
End Sub




All times are GMT +1. The time now is 12:05 PM.

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