+ Reply to Thread
Results 1 to 2 of 2

Data validation dependent of value of option button

  1. #1

    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


  2. #2
    Charlie
    Guest

    RE: 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


    "[email protected]" 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
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1