PDA

View Full Version : Solved: User form to appear when certain cell are clicked



BENSON
05-31-2007, 11:56 PM
I thought I knew this one but cant seem to get the right code.The code shown below works when cell B1 is selected.What I wish to do is extend the code to work on cells B1-B45


If Target.Address = "$B$1" Then UserForm1.Show



I have tried the following code but it does not work


If Target.Address = "$B$1:SB$45" Then UserForm1.Show


Thks for any help youcan give

blue_bogdan
06-01-2007, 12:06 AM
I thought I knew this one but cant seem to get the right code.The code shown below works when cell B1 is selected.What I wish to do is extend the code to work on cells B1-B45


If Target.Address = "$B$1" Then UserForm1.Show


I have tried the following code but it does not work


If Target.Address = "$B$1:SB$45" Then UserForm1.Show

Thks for any help youcan give
Well... I think you could try the following.... i'm just guessing...


For i=1 to 45
If Target.Address="B"&i then UserForm1.Show
End If
Next i

And this I hope solves the horisontal problem.... but the vertical....

BENSON
06-01-2007, 12:11 AM
I tried it, but does not work ,but thanks anyway

Charlize
06-01-2007, 12:39 AM
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("B1:B45")) Is Nothing Then
MsgBox Target.Address, vbInformation
Else
MsgBox "Click in between B1:B45", vbInformation
End If
End Sub

BENSON
06-01-2007, 05:22 AM
MANY THANKS

malik641
06-01-2007, 05:35 AM
What if it is a range of cells that partly intersects B1:B45? Do you want the userform to show when even 1 of those cells is in the selection?

Charlize
06-01-2007, 05:41 AM
What if it is a range of cells that partly intersects B1:B45? Do you want the userform to show when even 1 of those cells is in the selection?Normally I would add something like selection.count but if I doubleclick on a cell, is the selection that I made earlier gone or is it still active (maybe with control click ?)