Activate Userform with cell selection in excel

  Desert Andy 10:04 18 Dec 2007
Locked

I have set up a cell validation in an excel worksheet. If possible I would like to activate a userform if the user selects a particular value. I know its possible to write code for a selection change in vb, can I write code so that if the user selects the value 2 in a certain cell, a userform appears.
Many thanks for your help.

  VoG II 11:19 18 Dec 2007

Right click the sheet tab, View Code and paste in

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" And Target.Value = 2 Then UserForm1.Show
End Sub


This works with values typed into a cell but I haven't tried it with a validation list.

  MADMACx9 12:16 18 Dec 2007

not a very elegant method but

in VB (Alt f11)insert module

Function CALL_USERFORM(QUANTITY)
If QUANTITY = 2 Then UserForm1.Show
End Function

For example:- if (A1) is the test cell then
in (B1) enter formula "= CALL_USERFORM(A1)"

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Xiaomi Mi Mix 2 review

See mcbess's iconic style animated for Mercedes-Benz

iPhone X news: Release date, price, new features & specs

Black Friday 2017 : date, sites participants & bonnes affaires