Deactivate Data Validation with "IF" - Microsoft Community


hi,

eg.

i have drop down list @ a1 (as per below) :

one
two
three

i've selected "two" list , 'd a1 show "done" if there wording in a2.

which mean if a2 blank a1 remain "two", if there wording in a2, a1 list deactivate , show "done".

thanks
bao

1) copy code.
2) right-click sheet tab of interest.
3) select "view code"
4) paste code window appears.
5) save file macro-enabled .xlsm file.
6) make changes needed


private sub worksheet_change(byval target range)
    if intersect(target, range("a1:a2")) nothing exit sub
    if target.value = "" or range("a2").value = "" exit sub

    'not sure if want change value when a1 2  or value, maybe need this

    ' if  range("a1").value <> "two" exit sub

    'turn off events keep out of loops
    application.enableevents = false

    range("a1").validation.delete
    range("a1").value = "done"

    'turn events on ready next change
    application.enableevents = true
end sub

          


Office / Excel / Microsoft Office Programming / Office 2013



Comments

Popular posts from this blog

Getting ErrorCode: 120018 when trying to access Microsoft account - Microsoft Community

The message was sent to a distribution list ‎(DL)‎ - Microsoft Community

Activation Error 0x8004FE93 - Microsoft Community